From c5ada110ab8b9938625dc4e4a7a00080b1c6069c Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Mon, 30 Mar 2026 09:27:41 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20r=C3=A9soudre=20series=5Fid=20dans=20tor?= =?UTF-8?q?rent=5Fdownloads=20via=20JOIN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La table torrent_downloads ne stockait pas series_id. Le DTO l'exposait comme optional mais était toujours null, causant des liens KO en page downloads (fallback sur series_name alors que la route attend un UUID). Ajout d'un LEFT JOIN series sur (library_id, LOWER(name)) dans la query list_torrent_downloads pour résoudre le series_id dynamiquement. Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/torrent_import.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/api/src/torrent_import.rs b/apps/api/src/torrent_import.rs index 70a7bfb..09c8ed0 100644 --- a/apps/api/src/torrent_import.rs +++ b/apps/api/src/torrent_import.rs @@ -28,6 +28,7 @@ pub struct TorrentNotifyRequest { pub struct TorrentDownloadDto { pub id: String, pub library_id: String, + pub series_id: Option, pub series_name: String, pub expected_volumes: Vec, pub qb_hash: Option, @@ -104,9 +105,12 @@ pub async fn list_torrent_downloads( State(state): State, ) -> Result>, ApiError> { let rows = sqlx::query( - "SELECT id, library_id, series_name, expected_volumes, qb_hash, content_path, \ - status, imported_files, error_message, progress, download_speed, eta, created_at, updated_at \ - FROM torrent_downloads ORDER BY created_at DESC LIMIT 100", + "SELECT td.id, td.library_id, td.series_name, td.expected_volumes, td.qb_hash, td.content_path, \ + td.status, td.imported_files, td.error_message, td.progress, td.download_speed, td.eta, \ + td.created_at, td.updated_at, s.id AS series_id \ + FROM torrent_downloads td \ + LEFT JOIN series s ON s.library_id = td.library_id AND LOWER(s.name) = LOWER(td.series_name) \ + ORDER BY td.created_at DESC LIMIT 100", ) .fetch_all(&state.pool) .await?; @@ -116,12 +120,14 @@ pub async fn list_torrent_downloads( .map(|row| { let id: Uuid = row.get("id"); let library_id: Uuid = row.get("library_id"); + let series_id: Option = row.get("series_id"); let expected_volumes: Vec = row.get("expected_volumes"); let created_at: DateTime = row.get("created_at"); let updated_at: DateTime = row.get("updated_at"); TorrentDownloadDto { id: id.to_string(), library_id: library_id.to_string(), + series_id: series_id.map(|u| u.to_string()), series_name: row.get("series_name"), expected_volumes, qb_hash: row.get("qb_hash"),