feat(api): add per-chapter requeue scope for dead jobs
Lets the admin manga page requeue a single failed chapter's dead job(s) inline, without a job id. Adds RequeueScope::Chapter + the matching request variant and a repo test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -706,6 +706,8 @@ pub enum RequeueScope {
|
||||
All,
|
||||
/// Dead jobs whose chapter belongs to this manga.
|
||||
Manga(Uuid),
|
||||
/// Dead jobs for a single chapter.
|
||||
Chapter(Uuid),
|
||||
/// A single dead job by its id.
|
||||
Job(Uuid),
|
||||
}
|
||||
@@ -751,6 +753,18 @@ pub async fn requeue_dead_jobs(pool: &PgPool, scope: RequeueScope) -> sqlx::Resu
|
||||
.await?
|
||||
.rows_affected()
|
||||
}
|
||||
RequeueScope::Chapter(chapter_id) => {
|
||||
sqlx::query(&format!(
|
||||
"UPDATE crawler_jobs {SET} \
|
||||
WHERE state = 'dead' \
|
||||
AND (payload->>'chapter_id')::uuid = $1 \
|
||||
{NO_LIVE_DUP}"
|
||||
))
|
||||
.bind(chapter_id)
|
||||
.execute(pool)
|
||||
.await?
|
||||
.rows_affected()
|
||||
}
|
||||
RequeueScope::Job(job_id) => {
|
||||
sqlx::query(&format!(
|
||||
"UPDATE crawler_jobs {SET} WHERE state = 'dead' AND id = $1 {NO_LIVE_DUP}"
|
||||
|
||||
Reference in New Issue
Block a user