2021-08-19 21:55:45 +09:00
|
|
|
import define from '../define';
|
|
|
|
import { NoteReactions, Notes, Users } from '@/models/index';
|
|
|
|
import { federationChart, driveChart } from '@/services/chart/index';
|
2017-08-12 15:17:03 +09:00
|
|
|
|
2018-11-02 13:47:44 +09:00
|
|
|
export const meta = {
|
2022-01-18 22:27:10 +09:00
|
|
|
requireCredential: false,
|
2018-11-02 13:47:44 +09:00
|
|
|
|
2019-02-23 11:20:58 +09:00
|
|
|
tags: ['meta'],
|
|
|
|
|
2018-11-02 13:47:44 +09:00
|
|
|
params: {
|
2019-02-25 03:30:22 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
res: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2019-02-25 03:30:22 +09:00
|
|
|
properties: {
|
|
|
|
notesCount: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2019-02-25 03:30:22 +09:00
|
|
|
},
|
|
|
|
originalNotesCount: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2019-02-25 03:30:22 +09:00
|
|
|
},
|
|
|
|
usersCount: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2019-02-25 03:30:22 +09:00
|
|
|
},
|
|
|
|
originalUsersCount: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2019-02-25 03:30:22 +09:00
|
|
|
},
|
|
|
|
instances: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2019-02-25 03:30:22 +09:00
|
|
|
},
|
2021-03-06 22:34:11 +09:00
|
|
|
driveUsageLocal: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
driveUsageRemote: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-01-18 22:27:10 +09:00
|
|
|
} as const;
|
2018-11-02 13:47:44 +09:00
|
|
|
|
2022-01-03 02:12:50 +09:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2019-02-22 11:46:58 +09:00
|
|
|
export default define(meta, async () => {
|
2020-12-05 18:18:37 +09:00
|
|
|
const [
|
|
|
|
notesCount,
|
2019-04-23 22:35:26 +09:00
|
|
|
originalNotesCount,
|
|
|
|
usersCount,
|
|
|
|
originalUsersCount,
|
2020-12-05 18:18:37 +09:00
|
|
|
reactionsCount,
|
|
|
|
//originalReactionsCount,
|
2019-04-23 22:35:26 +09:00
|
|
|
instances,
|
|
|
|
] = await Promise.all([
|
2019-05-25 08:35:16 +09:00
|
|
|
Notes.count({ cache: 3600000 }), // 1 hour
|
|
|
|
Notes.count({ where: { userHost: null }, cache: 3600000 }),
|
|
|
|
Users.count({ cache: 3600000 }),
|
|
|
|
Users.count({ where: { host: null }, cache: 3600000 }),
|
2020-12-05 18:18:37 +09:00
|
|
|
NoteReactions.count({ cache: 3600000 }), // 1 hour
|
|
|
|
//NoteReactions.count({ where: { userHost: null }, cache: 3600000 }),
|
2020-03-07 11:23:31 +09:00
|
|
|
federationChart.getChart('hour', 1, null).then(chart => chart.instance.total[0]),
|
2019-04-07 21:50:36 +09:00
|
|
|
]);
|
|
|
|
|
|
|
|
return {
|
2019-04-23 22:35:26 +09:00
|
|
|
notesCount,
|
|
|
|
originalNotesCount,
|
|
|
|
usersCount,
|
|
|
|
originalUsersCount,
|
2020-12-05 18:18:37 +09:00
|
|
|
reactionsCount,
|
|
|
|
//originalReactionsCount,
|
2019-04-23 22:35:26 +09:00
|
|
|
instances,
|
2022-02-06 00:43:22 +09:00
|
|
|
driveUsageLocal: 0,
|
|
|
|
driveUsageRemote: 0,
|
2019-04-07 21:50:36 +09:00
|
|
|
};
|
2019-02-22 11:46:58 +09:00
|
|
|
});
|