refactor: better types for getList and getDeletedAfter (#16926)

This commit is contained in:
Jason Rasmussen 2025-03-17 15:32:12 -04:00 committed by GitHub
parent 93907a89d8
commit 6a40aa83b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 342 additions and 194 deletions

View file

@ -188,15 +188,9 @@ export class UserService extends BaseService {
@OnJob({ name: JobName.USER_DELETE_CHECK, queue: QueueName.BACKGROUND_TASK })
async handleUserDeleteCheck(): Promise<JobStatus> {
const users = await this.userRepository.getDeletedUsers();
const config = await this.getConfig({ withCache: false });
await this.jobRepository.queueAll(
users.flatMap((user) =>
this.isReadyForDeletion(user, config.user.deleteDelay)
? [{ name: JobName.USER_DELETION, data: { id: user.id } }]
: [],
),
);
const users = await this.userRepository.getDeletedAfter(DateTime.now().minus({ days: config.user.deleteDelay }));
await this.jobRepository.queueAll(users.map((user) => ({ name: JobName.USER_DELETION, data: { id: user.id } })));
return JobStatus.SUCCESS;
}