Feature/add lastRequestAt to analytics (#4010)

* Add lastRequestAt to Analytics
pull/4011/head
Thomas Kaul 3 weeks ago committed by GitHub
parent 5f56812125
commit a80ca507f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -641,7 +641,7 @@ export class AdminService {
} }
private async getUsersWithAnalytics(): Promise<AdminUsers['users']> { private async getUsersWithAnalytics(): Promise<AdminUsers['users']> {
let orderBy: any = { let orderBy: Prisma.UserOrderByWithRelationInput = {
createdAt: 'desc' createdAt: 'desc'
}; };
let where: Prisma.UserWhereInput; let where: Prisma.UserWhereInput;
@ -649,7 +649,7 @@ export class AdminService {
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
orderBy = { orderBy = {
Analytics: { Analytics: {
updatedAt: 'desc' lastRequestAt: 'desc'
} }
}; };
where = { where = {

@ -46,7 +46,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
update: { update: {
country, country,
activityCount: { increment: 1 }, activityCount: { increment: 1 },
updatedAt: new Date() lastRequestAt: new Date()
}, },
where: { userId: user.id } where: { userId: user.id }
}); });

@ -142,7 +142,7 @@ export class InfoService {
}, },
{ {
Analytics: { Analytics: {
updatedAt: { lastRequestAt: {
gt: subDays(new Date(), aDays) 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) activityCount Int @default(0)
country String? country String?
dataProviderGhostfolioDailyRequests Int @default(0) dataProviderGhostfolioDailyRequests Int @default(0)
lastRequestAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
userId String @id userId String @id
User User @relation(fields: [userId], onDelete: Cascade, references: [id]) User User @relation(fields: [userId], onDelete: Cascade, references: [id])
@@index([lastRequestAt])
@@index([updatedAt]) @@index([updatedAt])
} }

Loading…
Cancel
Save