databse wipe
This commit is contained in:
@@ -204,5 +204,14 @@ def get_stats() -> dict:
|
||||
}
|
||||
|
||||
|
||||
def clear_sync_data() -> dict:
|
||||
"""Delete all processed_zips, uploaded_books, and sync_runs rows. Settings are kept."""
|
||||
with get_db() as conn:
|
||||
zips = conn.execute("DELETE FROM processed_zips").rowcount
|
||||
books = conn.execute("DELETE FROM uploaded_books").rowcount
|
||||
runs = conn.execute("DELETE FROM sync_runs").rowcount
|
||||
return {"zips": zips, "books": books, "runs": runs}
|
||||
|
||||
|
||||
def _now() -> str:
|
||||
return datetime.now(timezone.utc).isoformat()
|
||||
|
||||
@@ -174,6 +174,15 @@ async def test_calibre():
|
||||
return {"ok": ok, "message": message}
|
||||
|
||||
|
||||
# --- Data reset ---
|
||||
|
||||
@app.post("/settings/reset-sync-data")
|
||||
async def reset_sync_data():
|
||||
counts = db.clear_sync_data()
|
||||
log.info("Sync data cleared: %s", counts)
|
||||
return RedirectResponse("/settings?reset=1", status_code=303)
|
||||
|
||||
|
||||
# --- JSON status API ---
|
||||
|
||||
@app.get("/api/status")
|
||||
|
||||
@@ -153,6 +153,9 @@ tr:hover td { background: rgba(255,255,255,0.02); }
|
||||
.btn-secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
|
||||
.btn-secondary:hover { background: rgba(99,102,241,0.1); }
|
||||
.btn-disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
|
||||
.btn-danger { background: #dc2626; color: #fff; border: 1px solid #dc2626; }
|
||||
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
|
||||
.danger-zone { border-color: rgba(220,38,38,0.4); }
|
||||
|
||||
/* Forms */
|
||||
.form-section {
|
||||
|
||||
@@ -148,6 +148,17 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<section class="form-section danger-zone">
|
||||
<h2>Danger zone</h2>
|
||||
{% if request.query_params.get("reset") %}
|
||||
<div class="alert alert-success">Sync data cleared — all processed zip and book records have been deleted.</div>
|
||||
{% endif %}
|
||||
<p class="muted small">Deletes all records of processed zips, uploaded books, and sync run history. Your settings are kept. Use this to start fresh after test runs.</p>
|
||||
<form method="post" action="/settings/reset-sync-data" onsubmit="return confirm('Delete all sync data? This cannot be undone.')">
|
||||
<button type="submit" class="btn btn-danger">Delete all sync data</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
function toggleAuth(method) {
|
||||
document.getElementById("row-key").style.display = method === "key" ? "" : "none";
|
||||
|
||||
Reference in New Issue
Block a user