fix(stats): no hard-coded stats

This commit is contained in:
무라쿠모 2024-06-20 02:57:43 +09:00
parent 3f58ca2bda
commit 02335b24d8
No known key found for this signature in database
GPG key ID: 139D6573F92DA9F7
3 changed files with 12 additions and 12 deletions

View file

@ -4,7 +4,7 @@
*/ */
import { Injectable, Inject } from '@nestjs/common'; 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 type { MiUser } from '@/models/User.js';
import { AppLockService } from '@/core/AppLockService.js'; import { AppLockService } from '@/core/AppLockService.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
@ -37,7 +37,7 @@ export default class UsersChart extends Chart<typeof schema> { // eslint-disable
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> { protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
const [localCount, remoteCount] = await Promise.all([ const [localCount, remoteCount] = await Promise.all([
this.usersRepository.countBy({ host: IsNull() }), this.usersRepository.countBy({ host: IsNull(), usernameLower: Like("%.%") }),
this.usersRepository.countBy({ host: Not(IsNull()) }), this.usersRepository.countBy({ host: Not(IsNull()) }),
]); ]);

View file

@ -71,12 +71,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
) { ) {
super(meta, paramDef, async () => { super(meta, paramDef, async () => {
const notesChart = await this.notesChart.getChart('hour', 1, null); const notesChart = await this.notesChart.getChart('hour', 1, null);
const notesCount = notesChart.local.total[0] + notesChart.remote.total[0];
const originalNotesCount = notesChart.local.total[0]; const originalNotesCount = notesChart.local.total[0];
const notesCount = originalNotesCount + notesChart.remote.total[0];
const usersChart = await this.usersChart.getChart('hour', 1, null); const usersChart = await this.usersChart.getChart('hour', 1, null);
const usersCount = usersChart.local.total[0] + usersChart.remote.total[0]; const originalUsersCount = usersChart.local.total[0];
const originalUsersCount = usersChart.local.total[0] - 2; const usersCount = originalUsersCount + usersChart.remote.total[0];
const [ const [
reactionsCount, reactionsCount,

View file

@ -12,8 +12,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="icon"><i class="ti ti-users"></i></div> <div class="icon"><i class="ti ti-users"></i></div>
<div class="body"> <div class="body">
<div class="value"> <div class="value">
<MkNumber :value="stats.originalUsersCount" style="margin-right: 0.5em;"/> <MkNumber :value="stats?.originalUsersCount!" style="margin-right: 0.5em;"/>
<MkNumberDiff v-tooltip="i18n.ts.dayOverDayChanges" class="diff" :value="usersComparedToThePrevDay"></MkNumberDiff> <MkNumberDiff v-tooltip="i18n.ts.dayOverDayChanges" class="diff" :value="usersComparedToThePrevDay!"></MkNumberDiff>
</div> </div>
<div class="label">Users</div> <div class="label">Users</div>
</div> </div>
@ -22,8 +22,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="icon"><i class="ti ti-pencil"></i></div> <div class="icon"><i class="ti ti-pencil"></i></div>
<div class="body"> <div class="body">
<div class="value"> <div class="value">
<MkNumber :value="stats.originalNotesCount" style="margin-right: 0.5em;"/> <MkNumber :value="stats?.originalNotesCount!" style="margin-right: 0.5em;"/>
<MkNumberDiff v-tooltip="i18n.ts.dayOverDayChanges" class="diff" :value="notesComparedToThePrevDay"></MkNumberDiff> <MkNumberDiff v-tooltip="i18n.ts.dayOverDayChanges" class="diff" :value="notesComparedToThePrevDay!"></MkNumberDiff>
</div> </div>
<div class="label">Notes</div> <div class="label">Notes</div>
</div> </div>
@ -32,7 +32,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="icon"><i class="ti ti-planet"></i></div> <div class="icon"><i class="ti ti-planet"></i></div>
<div class="body"> <div class="body">
<div class="value"> <div class="value">
<MkNumber :value="stats.instances" style="margin-right: 0.5em;"/> <MkNumber :value="stats?.instances!" style="margin-right: 0.5em;"/>
</div> </div>
<div class="label">Instances</div> <div class="label">Instances</div>
</div> </div>
@ -85,11 +85,11 @@ onMounted(async () => {
onlineUsersCount.value = _onlineUsersCount; onlineUsersCount.value = _onlineUsersCount;
misskeyApiGet('charts/users', { limit: 2, span: 'day' }).then(chart => { misskeyApiGet('charts/users', { limit: 2, span: 'day' }).then(chart => {
usersComparedToThePrevDay.value = stats.value.originalUsersCount - chart.local.total[1]; usersComparedToThePrevDay.value = stats.value?.originalUsersCount! - chart.local.total[1];
}); });
misskeyApiGet('charts/notes', { limit: 2, span: 'day' }).then(chart => { misskeyApiGet('charts/notes', { limit: 2, span: 'day' }).then(chart => {
notesComparedToThePrevDay.value = stats.value.originalNotesCount - chart.local.total[1]; notesComparedToThePrevDay.value = stats.value?.originalNotesCount! - chart.local.total[1];
}); });
fetching.value = false; fetching.value = false;