2023-01-13 05:40:33 +01:00
|
|
|
import { Instances, NoteReactions, Notes, Users } from "@/models/index.js";
|
|
|
|
import define from "../define.js";
|
2023-06-12 10:16:36 +02:00
|
|
|
import { driveChart, notesChart, usersChart } from "@/services/chart/index.js";
|
2023-01-13 05:40:33 +01:00
|
|
|
import { IsNull } from "typeorm";
|
2017-08-12 08:17:03 +02:00
|
|
|
|
2018-11-02 05:47:44 +01:00
|
|
|
export const meta = {
|
2022-11-15 09:37:35 +01:00
|
|
|
requireCredential: false,
|
2021-07-20 20:51:59 +02:00
|
|
|
requireCredentialPrivateMode: true,
|
2018-11-02 05:47:44 +01:00
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
tags: ["meta"],
|
2019-02-23 03:20:58 +01:00
|
|
|
|
2019-02-24 19:30:22 +01:00
|
|
|
res: {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "object",
|
|
|
|
optional: false,
|
|
|
|
nullable: false,
|
2019-02-24 19:30:22 +01:00
|
|
|
properties: {
|
|
|
|
notesCount: {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "number",
|
|
|
|
optional: false,
|
|
|
|
nullable: false,
|
2019-02-24 19:30:22 +01:00
|
|
|
},
|
|
|
|
originalNotesCount: {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "number",
|
|
|
|
optional: false,
|
|
|
|
nullable: false,
|
2019-02-24 19:30:22 +01:00
|
|
|
},
|
|
|
|
usersCount: {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "number",
|
|
|
|
optional: false,
|
|
|
|
nullable: false,
|
2019-02-24 19:30:22 +01:00
|
|
|
},
|
|
|
|
originalUsersCount: {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "number",
|
|
|
|
optional: false,
|
|
|
|
nullable: false,
|
2019-02-24 19:30:22 +01:00
|
|
|
},
|
|
|
|
instances: {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "number",
|
|
|
|
optional: false,
|
|
|
|
nullable: false,
|
2019-02-24 19:30:22 +01:00
|
|
|
},
|
2021-03-06 14:34:11 +01:00
|
|
|
driveUsageLocal: {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "number",
|
|
|
|
optional: false,
|
|
|
|
nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
},
|
|
|
|
driveUsageRemote: {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "number",
|
|
|
|
optional: false,
|
|
|
|
nullable: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
} as const;
|
2018-11-02 05:47:44 +01:00
|
|
|
|
2022-02-20 05:15:40 +01:00
|
|
|
export const paramDef = {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "object",
|
2022-02-19 06:05:32 +01:00
|
|
|
properties: {},
|
|
|
|
required: [],
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
export default define(meta, paramDef, async () => {
|
2023-06-12 10:16:36 +02:00
|
|
|
const notesChartData = await notesChart.getChart("hour", 1, null);
|
|
|
|
const notesCount =
|
|
|
|
notesChartData.local.total[0] + notesChartData.remote.total[0];
|
|
|
|
const originalNotesCount = notesChartData.local.total[0];
|
|
|
|
|
|
|
|
const usersChartData = await usersChart.getChart("hour", 1, null);
|
|
|
|
const usersCount =
|
|
|
|
usersChartData.local.total[0] + usersChartData.remote.total[0];
|
|
|
|
const originalUsersCount = usersChartData.local.total[0];
|
|
|
|
const driveChartData = await driveChart.getChart("hour", 1, null);
|
2023-06-12 10:23:53 +02:00
|
|
|
//TODO: fixme currently returns 0
|
2023-06-12 10:16:36 +02:00
|
|
|
const driveUsageLocal = driveChartData.local.incSize[0];
|
|
|
|
const driveUsageRemote = driveChartData.remote.incSize[0];
|
|
|
|
|
2020-12-05 10:18:37 +01:00
|
|
|
const [
|
|
|
|
reactionsCount,
|
|
|
|
//originalReactionsCount,
|
2019-04-23 15:35:26 +02:00
|
|
|
instances,
|
|
|
|
] = await Promise.all([
|
2020-12-05 10:18:37 +01:00
|
|
|
NoteReactions.count({ cache: 3600000 }), // 1 hour
|
2022-03-26 07:34:00 +01:00
|
|
|
//NoteReactions.count({ where: { userHost: IsNull() }, cache: 3600000 }),
|
2022-02-12 09:33:29 +01:00
|
|
|
Instances.count({ cache: 3600000 }),
|
2019-04-07 14:50:36 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
return {
|
2019-04-23 15:35:26 +02:00
|
|
|
notesCount,
|
|
|
|
originalNotesCount,
|
|
|
|
usersCount,
|
|
|
|
originalUsersCount,
|
2020-12-05 10:18:37 +01:00
|
|
|
reactionsCount,
|
|
|
|
//originalReactionsCount,
|
2019-04-23 15:35:26 +02:00
|
|
|
instances,
|
2023-06-12 10:16:36 +02:00
|
|
|
driveUsageLocal,
|
|
|
|
driveUsageRemote,
|
2019-04-07 14:50:36 +02:00
|
|
|
};
|
2019-02-22 03:46:58 +01:00
|
|
|
});
|