summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/admin/queue/stats.ts
blob: bd64d2ac068c7dfeca05ace8fbd7989e806ec5d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import define from '../../../define';
import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '../../../../../queue';

export const meta = {
	desc: {
		'ja-JP': 'キューの状態を返します。',
		'en-US': 'Returns the status of the queue.'
	},

	tags: ['admin'],

	requireCredential: true as const,
	requireModerator: true,

	params: {},

	res: {
		type: 'object' as const,
		optional: false as const, nullable: false as const,
		properties: {
			deliver: {
				ref: 'QueueCount'
			},
			inbox: {
				ref: 'QueueCount'
			},
			db: {
				ref: 'QueueCount'
			},
			objectStorage: {
				ref: 'QueueCount'
			}
		}
	}
};

export default define(meta, async (ps) => {
	const deliverJobCounts = await deliverQueue.getJobCounts();
	const inboxJobCounts = await inboxQueue.getJobCounts();
	const dbJobCounts = await dbQueue.getJobCounts();
	const objectStorageJobCounts = await objectStorageQueue.getJobCounts();

	return {
		deliver: deliverJobCounts,
		inbox: inboxJobCounts,
		db: dbJobCounts,
		objectStorage: objectStorageJobCounts,
	};
});