|
|
@ -61,7 +61,7 @@ import { Injectable, Logger } from '@nestjs/common'; |
|
|
import { EventEmitter2 } from '@nestjs/event-emitter'; |
|
|
import { EventEmitter2 } from '@nestjs/event-emitter'; |
|
|
import { InjectThrottlerStorage, ThrottlerStorage } from '@nestjs/throttler'; |
|
|
import { InjectThrottlerStorage, ThrottlerStorage } from '@nestjs/throttler'; |
|
|
import { Prisma, Role, User } from '@prisma/client'; |
|
|
import { Prisma, Role, User } from '@prisma/client'; |
|
|
import { differenceInDays, min, subDays } from 'date-fns'; |
|
|
import { differenceInDays, subDays } from 'date-fns'; |
|
|
import { isNil, without } from 'lodash'; |
|
|
import { isNil, without } from 'lodash'; |
|
|
import { createHmac } from 'node:crypto'; |
|
|
import { createHmac } from 'node:crypto'; |
|
|
|
|
|
|
|
|
@ -169,16 +169,10 @@ export class UserService { |
|
|
return type; |
|
|
return type; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const datesOfFirstActivityByType = activitiesGroupedByType.map( |
|
|
// The groupBy is ordered by the minimum date, thus the first group
|
|
|
({ _min }) => { |
|
|
// carries the date of the first activity
|
|
|
return _min.date; |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const dateOfFirstActivity = |
|
|
const dateOfFirstActivity = |
|
|
datesOfFirstActivityByType.length > 0 |
|
|
activitiesGroupedByType[0]?._min.date ?? new Date(); |
|
|
? min(datesOfFirstActivityByType) |
|
|
|
|
|
: new Date(); |
|
|
|
|
|
|
|
|
|
|
|
const resolvedUserSettings = resolveUserSettings({ |
|
|
const resolvedUserSettings = resolveUserSettings({ |
|
|
impersonationUserSettings: impersonationUser?.settings |
|
|
impersonationUserSettings: impersonationUser?.settings |
|
|
|