perf: ⚡ use existing response
This commit is contained in:
parent
2c8f22cbb0
commit
1914e568bb
1 changed files with 3 additions and 9 deletions
|
@ -1,19 +1,13 @@
|
||||||
import { Entity } from "megalodon";
|
import { Entity } from "megalodon";
|
||||||
import config from "@/config/index.js";
|
import config from "@/config/index.js";
|
||||||
import { fetchMeta } from "@/misc/fetch-meta.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";
|
import { MAX_NOTE_TEXT_LENGTH, FILE_TYPE_BROWSERSAFE } from "@/const.js";
|
||||||
|
|
||||||
export async function getInstance(
|
export async function getInstance(
|
||||||
response: Entity.Instance,
|
response: Entity.Instance,
|
||||||
contact: Entity.Account,
|
contact: Entity.Account,
|
||||||
) {
|
) {
|
||||||
const [meta, totalUsers, totalStatuses] = await Promise.all([
|
const meta = await fetchMeta(true);
|
||||||
fetchMeta(true),
|
|
||||||
Users.count({ where: { host: IsNull() } }),
|
|
||||||
Notes.count({ where: { userHost: IsNull() } }),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uri: response.uri,
|
uri: response.uri,
|
||||||
|
@ -27,8 +21,8 @@ export async function getInstance(
|
||||||
version: `3.0.0 (compatible; Firefish ${config.version})`,
|
version: `3.0.0 (compatible; Firefish ${config.version})`,
|
||||||
urls: response.urls,
|
urls: response.urls,
|
||||||
stats: {
|
stats: {
|
||||||
user_count: await totalUsers,
|
user_count: response.stats.user_count,
|
||||||
status_count: await totalStatuses,
|
status_count: response.stats.status_count,
|
||||||
domain_count: response.stats.domain_count,
|
domain_count: response.stats.domain_count,
|
||||||
},
|
},
|
||||||
thumbnail: response.thumbnail || "/static-assets/transparent.png",
|
thumbnail: response.thumbnail || "/static-assets/transparent.png",
|
||||||
|
|
Loading…
Reference in a new issue