refactor(server): cron jobs (#2067)

This commit is contained in:
Jason Rasmussen
2023-03-24 08:19:48 -04:00
committed by GitHub
parent 1efc74dabc
commit e36b620020
5 changed files with 15 additions and 29 deletions

View File

@@ -426,7 +426,7 @@ describe(UserService.name, () => {
});
});
describe('handleUserDeleteCheck', () => {
describe('handleQueueUserDelete', () => {
it('should skip users not ready for deletion', async () => {
userRepositoryMock.getDeletedUsers.mockResolvedValue([
{},
@@ -435,7 +435,7 @@ describe(UserService.name, () => {
{ deletedAt: makeDeletedAt(5) },
] as UserEntity[]);
await sut.handleUserDeleteCheck();
await sut.handleQueueUserDelete();
expect(userRepositoryMock.getDeletedUsers).toHaveBeenCalled();
expect(jobMock.queue).not.toHaveBeenCalled();
@@ -445,7 +445,7 @@ describe(UserService.name, () => {
const user = { deletedAt: makeDeletedAt(10) };
userRepositoryMock.getDeletedUsers.mockResolvedValue([user] as UserEntity[]);
await sut.handleUserDeleteCheck();
await sut.handleQueueUserDelete();
expect(userRepositoryMock.getDeletedUsers).toHaveBeenCalled();
expect(jobMock.queue).toHaveBeenCalledWith({ name: JobName.USER_DELETION, data: { user } });

View File

@@ -141,7 +141,7 @@ export class UserService {
return { admin, password, provided: !!providedPassword };
}
async handleUserDeleteCheck() {
async handleQueueUserDelete() {
const users = await this.userRepository.getDeletedUsers();
for (const user of users) {
if (this.isReadyForDeletion(user)) {