yumechi-no-kuni/src/server/api/endpoints/admin/queue/stats.ts

50 lines
1 KiB
TypeScript
Raw Normal View History

import define from '../../../define';
2019-05-27 03:44:51 -05:00
import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '../../../../../queue';
export const meta = {
desc: {
'ja-JP': 'キューの状態を返します。',
'en-US': 'Returns the status of the queue.'
},
tags: ['admin'],
2020-02-15 06:33:32 -06:00
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();
2019-03-08 06:30:12 -06:00
const inboxJobCounts = await inboxQueue.getJobCounts();
2019-05-27 03:44:51 -05:00
const dbJobCounts = await dbQueue.getJobCounts();
const objectStorageJobCounts = await objectStorageQueue.getJobCounts();
return {
deliver: deliverJobCounts,
2019-05-27 03:44:51 -05:00
inbox: inboxJobCounts,
db: dbJobCounts,
objectStorage: objectStorageJobCounts,
};
});