Feature/add lastRequestAt to analytics (#4010)
* Add lastRequestAt to Analytics
This commit is contained in:
parent
5f56812125
commit
a80ca507f8
@ -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])
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user