Browse Source
Feature/add lastRequestAt to analytics (#4010)
* Add lastRequestAt to Analytics
pull/4011/head
Thomas Kaul
3 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
11 additions and
4 deletions
-
apps/api/src/app/admin/admin.service.ts
-
apps/api/src/app/auth/jwt.strategy.ts
-
apps/api/src/app/info/info.service.ts
-
prisma/migrations/20241102121004_added_last_request_at_to_analytics/migration.sql
-
prisma/schema.prisma
|
|
@ -641,7 +641,7 @@ export class AdminService { |
|
|
|
} |
|
|
|
|
|
|
|
private async getUsersWithAnalytics(): Promise<AdminUsers['users']> { |
|
|
|
let orderBy: any = { |
|
|
|
let orderBy: Prisma.UserOrderByWithRelationInput = { |
|
|
|
createdAt: 'desc' |
|
|
|
}; |
|
|
|
let where: Prisma.UserWhereInput; |
|
|
@ -649,7 +649,7 @@ export class AdminService { |
|
|
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { |
|
|
|
orderBy = { |
|
|
|
Analytics: { |
|
|
|
updatedAt: 'desc' |
|
|
|
lastRequestAt: 'desc' |
|
|
|
} |
|
|
|
}; |
|
|
|
where = { |
|
|
|
|
|
@ -46,7 +46,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') { |
|
|
|
update: { |
|
|
|
country, |
|
|
|
activityCount: { increment: 1 }, |
|
|
|
updatedAt: new Date() |
|
|
|
lastRequestAt: new Date() |
|
|
|
}, |
|
|
|
where: { userId: user.id } |
|
|
|
}); |
|
|
|
|
|
@ -142,7 +142,7 @@ export class InfoService { |
|
|
|
}, |
|
|
|
{ |
|
|
|
Analytics: { |
|
|
|
updatedAt: { |
|
|
|
lastRequestAt: { |
|
|
|
gt: subDays(new Date(), aDays) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
@ -0,0 +1,5 @@ |
|
|
|
-- AlterTable |
|
|
|
ALTER TABLE "Analytics" ADD COLUMN "lastRequestAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP; |
|
|
|
|
|
|
|
-- CreateIndex |
|
|
|
CREATE INDEX "Analytics_lastRequestAt_idx" ON "Analytics"("lastRequestAt"); |
|
|
@ -68,10 +68,12 @@ model Analytics { |
|
|
|
activityCount Int @default(0) |
|
|
|
country String? |
|
|
|
dataProviderGhostfolioDailyRequests Int @default(0) |
|
|
|
lastRequestAt DateTime @default(now()) |
|
|
|
updatedAt DateTime @updatedAt |
|
|
|
userId String @id |
|
|
|
User User @relation(fields: [userId], onDelete: Cascade, references: [id]) |
|
|
|
|
|
|
|
@@index([lastRequestAt]) |
|
|
|
@@index([updatedAt]) |
|
|
|
} |
|
|
|
|
|
|
|