From 0299895869be5bdbbb858fe5e13de4207dbd6be2 Mon Sep 17 00:00:00 2001 From: Steppenstreuner Date: Fri, 28 Aug 2026 13:37:33 +0200 Subject: [PATCH] add(chore): bulk requests --- static/app.js | 43 ++++++++++++++++++++++++++----------- static/index.html | 11 ++++++++++ tests/test_import_flow.py | 28 ++++++++++++++++++++++++ tests/test_matcher.py | 13 ++++++++++- wordarr/api/imports.py | 4 ++-- wordarr/api/requests.py | 40 ++++++++++++++++++++++++++++++++++ wordarr/importer/matcher.py | 15 ++++++++++++- wordarr/importer/scanner.py | 8 ++++--- 8 files changed, 143 insertions(+), 19 deletions(-) diff --git a/static/app.js b/static/app.js index d5969ca..fef8863 100644 --- a/static/app.js +++ b/static/app.js @@ -182,18 +182,36 @@ $("#manual-form").addEventListener("submit", async (e) => { const data = Object.fromEntries(new FormData(e.target)); if (!data.library_id) { toast("Keine Library gewählt", true); return; } try { - await api("/api/requests", { - method: "POST", - body: JSON.stringify({ - library_id: parseInt(data.library_id), - title: data.title, authors: data.authors, series: data.series, - external_id: data.external_id, - year: data.year ? parseInt(data.year) : null, - volume: data.volume ? parseInt(data.volume) : null, - }), - }); + if (data.volume_to) { + if (!data.volume) { + toast("Für Bulk bitte Start-Band angeben", true); + return; + } + const created = await api("/api/requests/bulk", { + method: "POST", + body: JSON.stringify({ + library_id: parseInt(data.library_id), + series: data.series || data.title, authors: data.authors, + volume_from: parseInt(data.volume), + volume_to: parseInt(data.volume_to), + year: data.year ? parseInt(data.year) : null, + }), + }); + toast(`${created.length} Anfragen angelegt`); + } else { + await api("/api/requests", { + method: "POST", + body: JSON.stringify({ + library_id: parseInt(data.library_id), + title: data.title, authors: data.authors, series: data.series, + external_id: data.external_id, + year: data.year ? parseInt(data.year) : null, + volume: data.volume ? parseInt(data.volume) : null, + }), + }); + toast("Anfrage angelegt"); + } e.target.reset(); - toast("Anfrage angelegt"); } catch (err) { toast(err.message, true); } }); @@ -241,8 +259,9 @@ let missingReqs = []; $("#scan-btn").addEventListener("click", async () => { $("#scan-info").textContent = "Scanne…"; try { + const split = $("#split-dirs").checked; const [scan, reqs] = await Promise.all([ - api("/api/import/scan"), + api("/api/import/scan?split_dirs=" + split), api("/api/requests?status=missing"), ]); scanItems = scan.items; diff --git a/static/index.html b/static/index.html index e6462f1..57190c3 100644 --- a/static/index.html +++ b/static/index.html @@ -48,6 +48,13 @@ +