Browse Source

Reset benchmark in user settings (#2233)

pull/2235/head
Thomas Kaul 1 year ago
committed by GitHub
parent
commit
9036f53e7d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      apps/api/src/app/user/user.service.ts
  2. 3
      apps/api/src/services/configuration/configuration.service.ts
  3. 1
      libs/common/src/lib/config.ts

14
apps/api/src/app/user/user.service.ts

@ -4,7 +4,11 @@ import { ConfigurationService } from '@ghostfolio/api/services/configuration/con
import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service'; import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service';
import { PropertyService } from '@ghostfolio/api/services/property/property.service'; import { PropertyService } from '@ghostfolio/api/services/property/property.service';
import { TagService } from '@ghostfolio/api/services/tag/tag.service'; import { TagService } from '@ghostfolio/api/services/tag/tag.service';
import { PROPERTY_IS_READ_ONLY_MODE, locale } from '@ghostfolio/common/config'; import {
DEFAULT_CURRENCY,
PROPERTY_IS_READ_ONLY_MODE,
locale
} from '@ghostfolio/common/config';
import { User as IUser, UserSettings } from '@ghostfolio/common/interfaces'; import { User as IUser, UserSettings } from '@ghostfolio/common/interfaces';
import { import {
getPermissions, getPermissions,
@ -21,8 +25,6 @@ const crypto = require('crypto');
@Injectable() @Injectable()
export class UserService { export class UserService {
public static DEFAULT_CURRENCY = 'USD';
private baseCurrency: string; private baseCurrency: string;
public constructor( public constructor(
@ -145,8 +147,7 @@ export class UserService {
// Set default value for base currency // Set default value for base currency
if (!(user.Settings.settings as UserSettings)?.baseCurrency) { if (!(user.Settings.settings as UserSettings)?.baseCurrency) {
(user.Settings.settings as UserSettings).baseCurrency = (user.Settings.settings as UserSettings).baseCurrency = DEFAULT_CURRENCY;
UserService.DEFAULT_CURRENCY;
} }
// Set default value for date range // Set default value for date range
@ -186,6 +187,9 @@ export class UserService {
if (Analytics?.activityCount % frequency === 1) { if (Analytics?.activityCount % frequency === 1) {
currentPermissions.push(permissions.enableSubscriptionInterstitial); currentPermissions.push(permissions.enableSubscriptionInterstitial);
} }
// Reset benchmark
user.Settings.settings.benchmark = undefined;
} }
if (user.subscription?.type === 'Premium') { if (user.subscription?.type === 'Premium') {

3
apps/api/src/services/configuration/configuration.service.ts

@ -1,4 +1,5 @@
import { Environment } from '@ghostfolio/api/services/interfaces/environment.interface'; import { Environment } from '@ghostfolio/api/services/interfaces/environment.interface';
import { DEFAULT_CURRENCY } from '@ghostfolio/common/config';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { DataSource } from '@prisma/client'; import { DataSource } from '@prisma/client';
import { bool, cleanEnv, host, json, num, port, str } from 'envalid'; import { bool, cleanEnv, host, json, num, port, str } from 'envalid';
@ -13,7 +14,7 @@ export class ConfigurationService {
ALPHA_VANTAGE_API_KEY: str({ default: '' }), ALPHA_VANTAGE_API_KEY: str({ default: '' }),
BASE_CURRENCY: str({ BASE_CURRENCY: str({
choices: ['AUD', 'CAD', 'CNY', 'EUR', 'GBP', 'JPY', 'RUB', 'USD'], choices: ['AUD', 'CAD', 'CNY', 'EUR', 'GBP', 'JPY', 'RUB', 'USD'],
default: 'USD' default: DEFAULT_CURRENCY
}), }),
BETTER_UPTIME_API_KEY: str({ default: '' }), BETTER_UPTIME_API_KEY: str({ default: '' }),
CACHE_QUOTES_TTL: num({ default: 1 }), CACHE_QUOTES_TTL: num({ default: 1 }),

1
libs/common/src/lib/config.ts

@ -35,6 +35,7 @@ export const DATA_GATHERING_QUEUE = 'DATA_GATHERING_QUEUE';
export const DATA_GATHERING_QUEUE_PRIORITY_LOW = Number.MAX_SAFE_INTEGER; export const DATA_GATHERING_QUEUE_PRIORITY_LOW = Number.MAX_SAFE_INTEGER;
export const DATA_GATHERING_QUEUE_PRIORITY_HIGH = 1; export const DATA_GATHERING_QUEUE_PRIORITY_HIGH = 1;
export const DEFAULT_CURRENCY = 'USD';
export const DEFAULT_DATE_FORMAT_MONTH_YEAR = 'MMM yyyy'; export const DEFAULT_DATE_FORMAT_MONTH_YEAR = 'MMM yyyy';
export const DEFAULT_LANGUAGE_CODE = 'en'; export const DEFAULT_LANGUAGE_CODE = 'en';
export const DEFAULT_PAGE_SIZE = 50; export const DEFAULT_PAGE_SIZE = 50;

Loading…
Cancel
Save