Add force-run button for parsers in the admin UI.
Allow re-enqueueing any idle parse job so operators can trigger a post fetch without waiting for the schedule. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -22,6 +22,7 @@ const jobs = ref<ParseJob[]>([]);
|
|||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const error = ref("");
|
const error = ref("");
|
||||||
const submitting = ref(false);
|
const submitting = ref(false);
|
||||||
|
const forcingJobId = ref<number | null>(null);
|
||||||
const editingJob = ref<ParseJob | null>(null);
|
const editingJob = ref<ParseJob | null>(null);
|
||||||
|
|
||||||
const editForm = ref({
|
const editForm = ref({
|
||||||
@@ -268,12 +269,21 @@ async function handleDelete(job: ParseJob) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleRetry(jobId: number) {
|
function canForceRun(job: ParseJob): boolean {
|
||||||
|
return job.status !== "queued" && job.status !== "running";
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleForceRun(jobId: number) {
|
||||||
|
forcingJobId.value = jobId;
|
||||||
|
error.value = "";
|
||||||
try {
|
try {
|
||||||
await retryJob(jobId);
|
await retryJob(jobId);
|
||||||
await loadJobs();
|
await loadJobs();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error.value = err instanceof Error ? err.message : "Не удалось перезапустить задание";
|
error.value =
|
||||||
|
err instanceof Error ? err.message : "Не удалось запустить запрос постов";
|
||||||
|
} finally {
|
||||||
|
forcingJobId.value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,12 +438,17 @@ onUnmounted(() => {
|
|||||||
<td class="actions-cell">
|
<td class="actions-cell">
|
||||||
<button class="btn btn-sm" type="button" @click="openEdit(job)">Изменить</button>
|
<button class="btn btn-sm" type="button" @click="openEdit(job)">Изменить</button>
|
||||||
<button
|
<button
|
||||||
v-if="job.status === 'failed' || job.status === 'error'"
|
|
||||||
class="btn btn-sm"
|
class="btn btn-sm"
|
||||||
type="button"
|
type="button"
|
||||||
@click="handleRetry(job.id)"
|
:disabled="!canForceRun(job) || forcingJobId === job.id"
|
||||||
|
:title="
|
||||||
|
canForceRun(job)
|
||||||
|
? 'Принудительно выполнить запрос постов'
|
||||||
|
: 'Парсер уже в очереди или выполняется'
|
||||||
|
"
|
||||||
|
@click="handleForceRun(job.id)"
|
||||||
>
|
>
|
||||||
Повторить
|
{{ forcingJobId === job.id ? "Запуск..." : "Запустить" }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-danger"
|
class="btn btn-sm btn-danger"
|
||||||
|
|||||||
Reference in New Issue
Block a user