管理画面のジョブキュー一覧の修正 (#5586)

* Fix: inboxのジョブキューが表示されない

* ジョブキューで試行回数等を表示するように

* DBとオブジェクトストレージのジョブキューが表示されるように
This commit is contained in:
MeiMei 2019-11-07 05:41:44 +09:00 committed by syuilo
parent 873444c3c6
commit 8ada1725bf
2 changed files with 25 additions and 12 deletions

View file

@ -48,14 +48,15 @@
</ui-select>
</ui-horizon-group>
<sequential-entrance animation="entranceFromTop" delay="25">
<div class="xvvuvgsv" v-for="job in jobs">
<div class="xvvuvgsv" v-for="job in jobs" :key="job.id">
<b>{{ job.id }}</b>
<template v-if="domain === 'deliver'">
<span>{{ job.data.to }}</span>
</template>
<template v-if="domain === 'inbox'">
<span>{{ job.activity.id }}</span>
<span>{{ job.data.activity.id }}</span>
</template>
<span>{{ `(${job.attempts}/${job.maxAttempts}, ${Math.floor((jobsFetched - job.timestamp) / 1000 / 60)}min)` }}</span>
</div>
</sequential-entrance>
<ui-info v-if="jobs.length == jobsLimit">{{ $t('result-is-truncated', { n: jobsLimit }) }}</ui-info>
@ -84,6 +85,7 @@ export default Vue.extend({
chartLimit: 200,
jobs: [],
jobsLimit: 50,
jobsFetched: Date.now(),
domain: 'deliver',
state: 'delayed',
faTasks, faPaperPlane, faInbox, faChartBar, faDatabase, faCloud
@ -140,6 +142,7 @@ export default Vue.extend({
state: this.state,
limit: this.jobsLimit
}).then(jobs => {
this.jobsFetched = Date.now(),
this.jobs = jobs;
});
},
@ -149,7 +152,8 @@ export default Vue.extend({
<style lang="stylus" scoped>
.xvvuvgsv
> b
margin-right 16px
margin-left -6px
> b, span
margin 0 6px
</style>

View file

@ -1,6 +1,6 @@
import $ from 'cafy';
import define from '../../../define';
import { deliverQueue, inboxQueue } from '../../../../../queue';
import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '../../../../../queue';
export const meta = {
tags: ['admin'],
@ -10,11 +10,11 @@ export const meta = {
params: {
domain: {
validator: $.str,
validator: $.str.or(['deliver', 'inbox', 'db', 'objectStorage']),
},
state: {
validator: $.str,
validator: $.str.or(['active', 'waiting', 'delayed']),
},
limit: {
@ -28,13 +28,22 @@ export default define(meta, async (ps) => {
const queue =
ps.domain === 'deliver' ? deliverQueue :
ps.domain === 'inbox' ? inboxQueue :
ps.domain === 'db' ? dbQueue :
ps.domain === 'objectStorage' ? objectStorageQueue :
null as never;
const jobs = await queue.getJobs([ps.state], 0, ps.limit!);
return jobs.map(job => ({
id: job.id,
data: job.data,
attempts: job.attemptsMade,
}));
return jobs.map(job => {
const data = job.data;
delete data.content;
delete data.user;
return {
id: job.id,
data,
attempts: job.attemptsMade,
maxAttempts: job.opts ? job.opts.attempts : 0,
timestamp: job.timestamp,
};
});
});