feat: bookmark create enqueues SyncChapterContent jobs (0.29.0)
After a successful bookmark insert, the create handler spawns a detached tokio task that calls pipeline::enqueue_pending_for_manga for every chapter of the manga where page_count = 0 and the source row is not dropped. Bookmark create returns 201 immediately; enqueue work happens in the background and its failure is logged without surfacing to the user (the daily cron sweeps anything missed). The Phase A dedup index handles re-bookmarks idempotently — deleting and recreating a bookmark does not duplicate in-flight jobs — and the Phase B worker pool drains them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ use uuid::Uuid;
|
||||
use crate::api::pagination::PagedResponse;
|
||||
use crate::app::AppState;
|
||||
use crate::auth::extractor::CurrentUser;
|
||||
use crate::crawler::pipeline;
|
||||
use crate::domain::{Bookmark, BookmarkSummary};
|
||||
use crate::error::{AppError, AppResult};
|
||||
use crate::repo;
|
||||
@@ -86,6 +87,29 @@ async fn create(
|
||||
input.page,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Fire-and-forget: kick off content syncs for any pending chapters of
|
||||
// the newly-bookmarked manga. The dedup index makes this idempotent
|
||||
// across repeated bookmarks of the same manga; failure here must not
|
||||
// surface to the user (the daily cron sweeps anything missed).
|
||||
let pool = state.db.clone();
|
||||
let manga_id = input.manga_id;
|
||||
tokio::spawn(async move {
|
||||
match pipeline::enqueue_pending_for_manga(&pool, manga_id).await {
|
||||
Ok(summary) => tracing::info!(
|
||||
%manga_id,
|
||||
inserted = summary.inserted,
|
||||
skipped = summary.skipped,
|
||||
failed = summary.failed,
|
||||
"bookmark hook: enqueued pending chapters"
|
||||
),
|
||||
Err(e) => tracing::warn!(
|
||||
%manga_id, error = ?e,
|
||||
"bookmark hook: enqueue_pending_for_manga failed"
|
||||
),
|
||||
}
|
||||
});
|
||||
|
||||
Ok((StatusCode::CREATED, Json(bookmark)))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user