Skip to content

Commit

Permalink
fix: rm bulk delete (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
annarhughes authored Aug 21, 2024
1 parent 8ed2260 commit e273b43
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
7 changes: 0 additions & 7 deletions src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ export class UserController {
return await this.userService.deleteUser(req['user'].user as UserEntity);
}

@ApiBearerAuth('access-token')
@Delete('/bulk-delete')
@UseGuards(SuperAdminAuthGuard)
async bulkDeleteUsers(): Promise<UserEntity[]> {
return await this.userService.bulkDeleteUsers();
}

// This route must go before the Delete user route below as we want nestjs to check against this one first
@ApiBearerAuth('access-token')
@Delete('/cypress')
Expand Down
19 changes: 1 addition & 18 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Logger } from 'src/logger/logger';
import { ServiceUserProfilesService } from 'src/service-user-profiles/service-user-profiles.service';
import { SubscriptionUserService } from 'src/subscription-user/subscription-user.service';
import { TherapySessionService } from 'src/therapy-session/therapy-session.service';
import { isProduction, SIGNUP_TYPE } from 'src/utils/constants';
import { SIGNUP_TYPE } from 'src/utils/constants';
import { FIREBASE_ERRORS } from 'src/utils/errors';
import { FIREBASE_EVENTS, USER_SERVICE_EVENTS } from 'src/utils/logs';
import { ILike, IsNull, Not, Repository } from 'typeorm';
Expand Down Expand Up @@ -327,23 +327,6 @@ export class UserService {
return deletedUsers;
}

public async bulkDeleteUsers(): Promise<UserEntity[]> {
if (isProduction) {
throw new Error('Bulk delete cannot be performed on production database');
}

let deletedUsers: UserEntity[];

try {
const users = await this.userRepository.find();

deletedUsers = await this.batchDeleteUsers(users);
} catch (error) {
this.logger.error(`deleteFilteredUsers - Unable to delete all users`, error);
}
return deletedUsers;
}

public async deleteCypressTestUsers(clean = false): Promise<UserEntity[]> {
let deletedUsers: UserEntity[];
try {
Expand Down

0 comments on commit e273b43

Please sign in to comment.