From 78a82935200c5aaad0091eb675bede1bc4387642 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 8 Mar 2019 13:03:38 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B8=E3=83=A7=E3=83=96=E3=81=AE=E6=95=B0?= =?UTF-8?q?=E3=82=92=E4=B8=80=E8=A6=A7=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/admin/views/queue.vue | 35 +++++++++++++++++++ src/queue/index.ts | 6 ++-- src/server/api/endpoints/admin/queue/stats.ts | 21 +++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 src/server/api/endpoints/admin/queue/stats.ts diff --git a/src/client/app/admin/views/queue.vue b/src/client/app/admin/views/queue.vue index fa9e3df78..ae3aa0db5 100644 --- a/src/client/app/admin/views/queue.vue +++ b/src/client/app/admin/views/queue.vue @@ -2,6 +2,34 @@
+
+
Deliver
+ + + Waiting + + + Active + + + Delayed + + +
+
+
Inbox
+ + + Waiting + + + Active + + + Delayed + + +
{{ $t('remove-all-jobs') }}
@@ -18,9 +46,16 @@ export default Vue.extend({ data() { return { + stats: null }; }, + created() { + this.$root.api('admin/queue/stats').then(stats => { + this.stats = stats; + }); + }, + methods: { async removeAllJobs() { const process = async () => { diff --git a/src/queue/index.ts b/src/queue/index.ts index d5294f836..93b103f5d 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -21,9 +21,9 @@ function initializeQueue(name: string) { } : null); } -const deliverQueue = initializeQueue('deliver'); -const inboxQueue = initializeQueue('inbox'); -const dbQueue = initializeQueue('db'); +export const deliverQueue = initializeQueue('deliver'); +export const inboxQueue = initializeQueue('inbox'); +export const dbQueue = initializeQueue('db'); export function deliver(user: ILocalUser, content: any, to: any) { if (content == null) return null; diff --git a/src/server/api/endpoints/admin/queue/stats.ts b/src/server/api/endpoints/admin/queue/stats.ts new file mode 100644 index 000000000..a90daa398 --- /dev/null +++ b/src/server/api/endpoints/admin/queue/stats.ts @@ -0,0 +1,21 @@ +import define from '../../../define'; +import { deliverQueue } from '../../../../../queue'; + +export const meta = { + tags: ['admin'], + + requireCredential: true, + requireModerator: true, + + params: {} +}; + +export default define(meta, async (ps) => { + const deliverJobCounts = await deliverQueue.getJobCounts(); + const inboxJobCounts = await deliverQueue.getJobCounts(); + + return { + deliver: deliverJobCounts, + inbox: inboxJobCounts + }; +});