Fixed 267U.pre2

This commit is contained in:
2026-07-26 18:25:37 +09:00
parent 50bfaeafdf
commit 317d00a284
1286 changed files with 80222 additions and 1 deletions
@@ -0,0 +1,36 @@
import Chart from "../core.js";
import { Users } from "../../../models/index.js";
import { Not, IsNull } from "typeorm";
import { name, schema } from "./entities/users.js";
/**
* ユーザー数に関するチャート
*/ export default class UsersChart extends Chart {
constructor(){
super(name, schema);
}
async tickMajor() {
const [localCount, remoteCount] = await Promise.all([
Users.countBy({
host: IsNull()
}),
Users.countBy({
host: Not(IsNull())
})
]);
return {
"local.total": localCount,
"remote.total": remoteCount
};
}
async tickMinor() {
return {};
}
async update(user, isAdditional) {
const prefix = Users.isLocalUser(user) ? "local" : "remote";
await this.commit({
[`${prefix}.total`]: isAdditional ? 1 : -1,
[`${prefix}.inc`]: isAdditional ? 1 : 0,
[`${prefix}.dec`]: isAdditional ? 0 : 1
});
}
}