fix(backend): mastodon stats conflate all indexed users and statuses
This commit is contained in:
parent
7051e445d3
commit
64bfb8f329
1 changed files with 9 additions and 3 deletions
|
@ -1,13 +1,19 @@
|
|||
import { Entity } from "megalodon";
|
||||
import config from "@/config/index.js";
|
||||
import { fetchMeta } from "@/misc/fetch-meta.js";
|
||||
import { Users, Notes } from "@/models/index.js";
|
||||
import { IsNull } from "typeorm";
|
||||
import { MAX_NOTE_TEXT_LENGTH, FILE_TYPE_BROWSERSAFE } from "@/const.js";
|
||||
|
||||
export async function getInstance(
|
||||
response: Entity.Instance,
|
||||
contact: Entity.Account,
|
||||
) {
|
||||
const meta = await fetchMeta(true);
|
||||
const [meta, totalUsers, totalStatuses] = await Promise.all([
|
||||
fetchMeta(),
|
||||
Users.count({ where: { host: IsNull() } }),
|
||||
Notes.count({ where: { userHost: IsNull() } }),
|
||||
]);
|
||||
|
||||
return {
|
||||
uri: response.uri,
|
||||
|
@ -21,8 +27,8 @@ export async function getInstance(
|
|||
version: `3.0.0 (compatible; Firefish ${config.version})`,
|
||||
urls: response.urls,
|
||||
stats: {
|
||||
user_count: response.stats.user_count,
|
||||
status_count: response.stats.status_count,
|
||||
user_count: totalUsers,
|
||||
status_count: totalStatuses,
|
||||
domain_count: response.stats.domain_count,
|
||||
},
|
||||
thumbnail: response.thumbnail || "/static-assets/transparent.png",
|
||||
|
|
Loading…
Reference in a new issue