diff --git a/apps/api/src/app/info/info.module.ts b/apps/api/src/app/info/info.module.ts index 75d681b5..a6b5b5b0 100644 --- a/apps/api/src/app/info/info.module.ts +++ b/apps/api/src/app/info/info.module.ts @@ -1,6 +1,7 @@ import { BenchmarkModule } from '@ghostfolio/api/app/benchmark/benchmark.module'; import { PlatformModule } from '@ghostfolio/api/app/platform/platform.module'; import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module'; +import { UserModule } from '@ghostfolio/api/app/user/user.module'; import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module'; import { DataGatheringModule } from '@ghostfolio/api/services/data-gathering/data-gathering.module'; import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module'; @@ -28,11 +29,11 @@ import { InfoService } from './info.service'; signOptions: { expiresIn: '30 days' } }), PlatformModule, - PrismaModule, PropertyModule, RedisCacheModule, SymbolProfileModule, - TagModule + TagModule, + UserModule ], providers: [InfoService] }) diff --git a/apps/api/src/app/info/info.service.ts b/apps/api/src/app/info/info.service.ts index 7eba432f..59df59f0 100644 --- a/apps/api/src/app/info/info.service.ts +++ b/apps/api/src/app/info/info.service.ts @@ -1,9 +1,9 @@ import { BenchmarkService } from '@ghostfolio/api/app/benchmark/benchmark.service'; import { PlatformService } from '@ghostfolio/api/app/platform/platform.service'; import { RedisCacheService } from '@ghostfolio/api/app/redis-cache/redis-cache.service'; +import { UserService } from '@ghostfolio/api/app/user/user.service'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; -import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service'; import { PropertyService } from '@ghostfolio/api/services/property/property.service'; import { TagService } from '@ghostfolio/api/services/tag/tag.service'; import { @@ -44,10 +44,10 @@ export class InfoService { private readonly exchangeRateDataService: ExchangeRateDataService, private readonly jwtService: JwtService, private readonly platformService: PlatformService, - private readonly prismaService: PrismaService, private readonly propertyService: PropertyService, private readonly redisCacheService: RedisCacheService, - private readonly tagService: TagService + private readonly tagService: TagService, + private readonly userService: UserService ) {} public async get(): Promise { @@ -145,12 +145,7 @@ export class InfoService { } private async countActiveUsers(aDays: number) { - return await this.prismaService.user.count({ - orderBy: { - Analytics: { - updatedAt: 'desc' - } - }, + return this.userService.count({ where: { AND: [ { @@ -223,10 +218,7 @@ export class InfoService { } private async countNewUsers(aDays: number) { - return await this.prismaService.user.count({ - orderBy: { - createdAt: 'desc' - }, + return this.userService.count({ where: { AND: [ { @@ -317,11 +309,10 @@ export class InfoService { return undefined; } - const stripeConfig = (await this.prismaService.property.findUnique({ - where: { key: PROPERTY_STRIPE_CONFIG } - })) ?? { value: '{}' }; - - return JSON.parse(stripeConfig.value); + return ( + ((await this.propertyService.getByKey(PROPERTY_STRIPE_CONFIG)) as any) ?? + {} + ); } private async getUptime(): Promise { diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index bbb17b69..88f4bc0b 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -37,6 +37,10 @@ export class UserService { this.baseCurrency = this.configurationService.get('BASE_CURRENCY'); } + public async count(args?: Prisma.UserCountArgs) { + return this.prismaService.user.count(args); + } + public async getUser( { Account, id, permissions, Settings, subscription }: UserWithSettings, aLocale = locale