refactor: users.total metric (#23158)

* refactor: users.total metric

* fix: broken test
This commit is contained in:
Jason Rasmussen
2025-10-22 10:18:17 -04:00
committed by GitHub
parent 0b941d78c4
commit a70843e2b4
10 changed files with 76 additions and 23 deletions
+3 -2
View File
@@ -103,7 +103,8 @@ export class UserAdminService extends BaseService {
const status = force ? UserStatus.Removing : UserStatus.Deleted;
const user = await this.userRepository.update(id, { status, deletedAt: new Date() });
this.telemetryRepository.api.addToGauge(`immich.users.total`, -1);
await this.eventRepository.emit('UserDelete', user);
if (force) {
await this.jobRepository.queue({ name: JobName.UserDelete, data: { id: user.id, force } });
@@ -116,7 +117,7 @@ export class UserAdminService extends BaseService {
await this.findOrFail(id, { withDeleted: true });
await this.albumRepository.restoreAll(id);
const user = await this.userRepository.restore(id);
this.telemetryRepository.api.addToGauge('immich.users.total', 1);
await this.eventRepository.emit('UserRestore', user);
return mapUserAdmin(user);
}