Added batch process and test
This commit is contained in:
@@ -60,6 +60,7 @@ async def dashboard(request: Request):
|
||||
runs = [dict(r) for r in db.get_recent_runs(10)]
|
||||
zips = [dict(z) for z in db.get_recent_zips(20)]
|
||||
interval = int(db.get_setting("scheduler_interval_minutes", "0") or "0")
|
||||
batch_size = int(db.get_setting("sync_batch_size", "0") or "0")
|
||||
return templates.TemplateResponse(
|
||||
"index.html",
|
||||
{
|
||||
@@ -70,6 +71,7 @@ async def dashboard(request: Request):
|
||||
"sync_running": sync.is_running(),
|
||||
"next_run": next_run_time(),
|
||||
"interval": interval,
|
||||
"batch_size": batch_size,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -116,6 +118,7 @@ async def save_settings(
|
||||
calibre_pass: str = Form(""),
|
||||
local_work_dir: str = Form("/tmp/calibresync"),
|
||||
scheduler_interval_minutes: str = Form("0"),
|
||||
sync_batch_size: str = Form("0"),
|
||||
):
|
||||
config.save({
|
||||
"sftp_host": sftp_host,
|
||||
@@ -130,12 +133,13 @@ async def save_settings(
|
||||
"calibre_pass": calibre_pass,
|
||||
"local_work_dir": local_work_dir,
|
||||
"scheduler_interval_minutes": scheduler_interval_minutes,
|
||||
"sync_batch_size": sync_batch_size,
|
||||
})
|
||||
_reschedule_auto_sync()
|
||||
return RedirectResponse("/settings?saved=1", status_code=303)
|
||||
|
||||
|
||||
# --- Sync trigger ---
|
||||
# --- Sync triggers ---
|
||||
|
||||
@app.post("/sync")
|
||||
async def trigger_sync(background_tasks: BackgroundTasks):
|
||||
@@ -145,6 +149,14 @@ async def trigger_sync(background_tasks: BackgroundTasks):
|
||||
return RedirectResponse("/?started=1", status_code=303)
|
||||
|
||||
|
||||
@app.post("/sync/test")
|
||||
async def trigger_test_sync(background_tasks: BackgroundTasks):
|
||||
if sync.is_running():
|
||||
return RedirectResponse("/?already_running=1", status_code=303)
|
||||
background_tasks.add_task(sync.run_sync, 1)
|
||||
return RedirectResponse("/?test_started=1", status_code=303)
|
||||
|
||||
|
||||
# --- JSON status API ---
|
||||
|
||||
@app.get("/api/status")
|
||||
|
||||
Reference in New Issue
Block a user