diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts index 57c471a18..2715d65d5 100644 --- a/apps/api/src/app/admin/admin.service.ts +++ b/apps/api/src/app/admin/admin.service.ts @@ -509,38 +509,9 @@ export class AdminService { }; } - public async getUsers({ - skip, - take = Number.MAX_SAFE_INTEGER - }: { - skip?: number; - take?: number; - }): Promise { - const [count, users] = await Promise.all([ - this.countUsersWithAnalytics(), - this.getUsersWithAnalytics({ skip, take }) - ]); - - return { count, users }; - } - public async getUser(id: string): Promise { const user = await this.prismaService.user.findUnique({ - where: { id }, select: { - id: true, - role: true, - provider: true, - createdAt: true, - updatedAt: true, - analytics: { - select: { - activityCount: true, - country: true, - dataProviderGhostfolioDailyRequests: true, - updatedAt: true - } - }, _count: { select: { accounts: true, @@ -548,49 +519,58 @@ export class AdminService { watchlist: true } }, - subscriptions: { - orderBy: { expiresAt: 'desc' }, - take: 3, - select: { - id: true, - expiresAt: true, - createdAt: true - } - }, - tags: { - select: { - id: true, - name: true - } - } - } + analytics: true, + createdAt: true, + id: true, + provider: true, + role: true, + subscriptions: true, + tags: true, + updatedAt: true + }, + where: { id } }); if (!user) { throw new NotFoundException(`User with ID ${id} not found`); } - const { _count, analytics, createdAt, id: userId, role, provider } = user; + const { _count, analytics, createdAt, provider, role, updatedAt } = user; return { - id: userId, - role, - provider, - createdAt, - updatedAt: user.updatedAt, accountCount: _count.accounts || 0, activityCount: _count.activities || 0, - watchlistCount: _count.watchlist || 0, analytics: { country: analytics?.country, dailyApiRequests: analytics?.dataProviderGhostfolioDailyRequests || 0, lastActivity: analytics?.updatedAt }, + createdAt, + id, + provider, + role, subscriptions: user.subscriptions, - tags: user.tags + tags: user.tags, + updatedAt, + watchlistCount: _count.watchlist || 0 }; } + public async getUsers({ + skip, + take = Number.MAX_SAFE_INTEGER + }: { + skip?: number; + take?: number; + }): Promise { + const [count, users] = await Promise.all([ + this.countUsersWithAnalytics(), + this.getUsersWithAnalytics({ skip, take }) + ]); + + return { count, users }; + } + public async patchAssetProfileData( { dataSource, symbol }: AssetProfileIdentifier, {