2023-07-26 22:31:52 -07:00
|
|
|
<!--
|
2024-02-13 07:59:27 -08:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-26 22:31:52 -07:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2022-12-22 22:21:55 -08:00
|
|
|
<template>
|
|
|
|
<div :class="$style.root">
|
|
|
|
<div class="_table status">
|
|
|
|
<div class="_row">
|
|
|
|
<div class="_cell" style="text-align: center;"><div class="_label">Process</div>{{ number(activeSincePrevTick) }}</div>
|
|
|
|
<div class="_cell" style="text-align: center;"><div class="_label">Active</div>{{ number(active) }}</div>
|
|
|
|
<div class="_cell" style="text-align: center;"><div class="_label">Waiting</div>{{ number(waiting) }}</div>
|
|
|
|
<div class="_cell" style="text-align: center;"><div class="_label">Delayed</div>{{ number(delayed) }}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="charts">
|
|
|
|
<div class="chart">
|
|
|
|
<div class="title">Process</div>
|
|
|
|
<XChart ref="chartProcess" type="process"/>
|
|
|
|
</div>
|
|
|
|
<div class="chart">
|
|
|
|
<div class="title">Active</div>
|
|
|
|
<XChart ref="chartActive" type="active"/>
|
|
|
|
</div>
|
|
|
|
<div class="chart">
|
|
|
|
<div class="title">Delayed</div>
|
|
|
|
<XChart ref="chartDelayed" type="delayed"/>
|
|
|
|
</div>
|
|
|
|
<div class="chart">
|
|
|
|
<div class="title">Waiting</div>
|
|
|
|
<XChart ref="chartWaiting" type="waiting"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-06 21:42:09 -08:00
|
|
|
import { markRaw, onMounted, onUnmounted, ref, shallowRef } from 'vue';
|
2024-08-29 18:58:59 -07:00
|
|
|
import * as Misskey from 'misskey-js';
|
2022-12-22 22:21:55 -08:00
|
|
|
import XChart from './overview.queue.chart.vue';
|
2024-08-29 18:58:59 -07:00
|
|
|
import type { ApQueueDomain } from '@/pages/admin/queue.vue';
|
2023-09-19 00:37:43 -07:00
|
|
|
import number from '@/filters/number.js';
|
|
|
|
import { useStream } from '@/stream.js';
|
2022-12-22 22:21:55 -08:00
|
|
|
|
2023-05-15 03:08:46 -07:00
|
|
|
const connection = markRaw(useStream().useChannel('queueStats'));
|
2022-12-22 22:21:55 -08:00
|
|
|
|
|
|
|
const activeSincePrevTick = ref(0);
|
|
|
|
const active = ref(0);
|
|
|
|
const delayed = ref(0);
|
|
|
|
const waiting = ref(0);
|
2023-12-06 21:42:09 -08:00
|
|
|
const chartProcess = shallowRef<InstanceType<typeof XChart>>();
|
|
|
|
const chartActive = shallowRef<InstanceType<typeof XChart>>();
|
|
|
|
const chartDelayed = shallowRef<InstanceType<typeof XChart>>();
|
|
|
|
const chartWaiting = shallowRef<InstanceType<typeof XChart>>();
|
2022-12-22 22:21:55 -08:00
|
|
|
|
|
|
|
const props = defineProps<{
|
2024-08-29 18:58:59 -07:00
|
|
|
domain: ApQueueDomain;
|
2022-12-22 22:21:55 -08:00
|
|
|
}>();
|
|
|
|
|
2024-08-29 18:58:59 -07:00
|
|
|
function onStats(stats: Misskey.entities.QueueStats) {
|
2022-12-22 22:21:55 -08:00
|
|
|
activeSincePrevTick.value = stats[props.domain].activeSincePrevTick;
|
|
|
|
active.value = stats[props.domain].active;
|
|
|
|
delayed.value = stats[props.domain].delayed;
|
|
|
|
waiting.value = stats[props.domain].waiting;
|
|
|
|
|
2023-12-06 21:42:09 -08:00
|
|
|
chartProcess.value.pushData(stats[props.domain].activeSincePrevTick);
|
|
|
|
chartActive.value.pushData(stats[props.domain].active);
|
|
|
|
chartDelayed.value.pushData(stats[props.domain].delayed);
|
|
|
|
chartWaiting.value.pushData(stats[props.domain].waiting);
|
2024-08-29 18:58:59 -07:00
|
|
|
}
|
2022-12-22 22:21:55 -08:00
|
|
|
|
2024-08-29 18:58:59 -07:00
|
|
|
function onStatsLog(statsLog: Misskey.entities.QueueStatsLog) {
|
|
|
|
const dataProcess: Misskey.entities.QueueStats[ApQueueDomain]['activeSincePrevTick'][] = [];
|
|
|
|
const dataActive: Misskey.entities.QueueStats[ApQueueDomain]['active'][] = [];
|
|
|
|
const dataDelayed: Misskey.entities.QueueStats[ApQueueDomain]['delayed'][] = [];
|
|
|
|
const dataWaiting: Misskey.entities.QueueStats[ApQueueDomain]['waiting'][] = [];
|
2022-12-22 22:21:55 -08:00
|
|
|
|
|
|
|
for (const stats of [...statsLog].reverse()) {
|
|
|
|
dataProcess.push(stats[props.domain].activeSincePrevTick);
|
|
|
|
dataActive.push(stats[props.domain].active);
|
|
|
|
dataDelayed.push(stats[props.domain].delayed);
|
|
|
|
dataWaiting.push(stats[props.domain].waiting);
|
|
|
|
}
|
|
|
|
|
2023-12-06 21:42:09 -08:00
|
|
|
chartProcess.value.setData(dataProcess);
|
|
|
|
chartActive.value.setData(dataActive);
|
|
|
|
chartDelayed.value.setData(dataDelayed);
|
|
|
|
chartWaiting.value.setData(dataWaiting);
|
2024-08-29 18:58:59 -07:00
|
|
|
}
|
2022-12-22 22:21:55 -08:00
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
connection.on('stats', onStats);
|
|
|
|
connection.on('statsLog', onStatsLog);
|
|
|
|
connection.send('requestLog', {
|
2023-07-13 15:59:54 -07:00
|
|
|
id: Math.random().toString().substring(2, 10),
|
2022-12-22 22:21:55 -08:00
|
|
|
length: 100,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
connection.off('stats', onStats);
|
|
|
|
connection.off('statsLog', onStatsLog);
|
|
|
|
connection.dispose();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
|
|
|
&:global {
|
|
|
|
> .status {
|
|
|
|
padding: 0 0 16px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .charts {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr 1fr;
|
2022-12-24 22:43:46 -08:00
|
|
|
gap: 12px;
|
2022-12-22 22:21:55 -08:00
|
|
|
|
|
|
|
> .chart {
|
|
|
|
min-width: 0;
|
|
|
|
padding: 16px;
|
|
|
|
background: var(--panel);
|
|
|
|
border-radius: var(--radius);
|
|
|
|
|
|
|
|
> .title {
|
|
|
|
font-size: 0.85em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-07 15:08:16 -07:00
|
|
|
</style>
|