From 89f4f0e5f4df75552d2aaf111a56f8cc0f796e2c Mon Sep 17 00:00:00 2001
From: dakkar <dakkar@thenautilus.net>
Date: Tue, 7 May 2024 20:17:53 +0000
Subject: [PATCH] don't count "system" local accounts in user chart - fixes
 #451

---
 packages/backend/src/core/chart/charts/users.ts | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/packages/backend/src/core/chart/charts/users.ts b/packages/backend/src/core/chart/charts/users.ts
index d148fc629b..840522ae9b 100644
--- a/packages/backend/src/core/chart/charts/users.ts
+++ b/packages/backend/src/core/chart/charts/users.ts
@@ -4,7 +4,7 @@
  */
 
 import { Injectable, Inject } from '@nestjs/common';
-import { Not, IsNull, DataSource } from 'typeorm';
+import { Not, IsNull, Like, DataSource } from 'typeorm';
 import type { MiUser } from '@/models/User.js';
 import { AppLockService } from '@/core/AppLockService.js';
 import { DI } from '@/di-symbols.js';
@@ -37,7 +37,10 @@ export default class UsersChart extends Chart<typeof schema> { // eslint-disable
 
 	protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
 		const [localCount, remoteCount] = await Promise.all([
-			this.usersRepository.countBy({ host: IsNull() }),
+			// that Not(Like()) is ugly, but it matches the logic in
+			// packages/backend/src/models/User.ts to not count "system"
+			// accounts
+			this.usersRepository.countBy({ host: IsNull(), username: Not(Like('%.%')) }),
 			this.usersRepository.countBy({ host: Not(IsNull()) }),
 		]);