mirror of
https://github.com/zvx-echo6/recon.git
synced 2026-05-20 06:34:40 +02:00
Add scraper job queue management (delete, clear failed)
New API endpoints: DELETE single job, clear all failed/cancelled. Dashboard now shows Delete buttons on completed/failed jobs, Retry+Delete on failed jobs, and a Clear Failed bulk action. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1ce9a3731f
commit
45c3bb8d56
3 changed files with 60 additions and 4 deletions
30
lib/api.py
30
lib/api.py
|
|
@ -2373,6 +2373,36 @@ def api_scraper_retry(job_id):
|
|||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
@app.route('/api/scraper/delete/<int:job_id>', methods=['POST'])
|
||||
def api_scraper_delete(job_id):
|
||||
"""Delete a scrape job (only if not currently running)."""
|
||||
db = StatusDB()
|
||||
job = db.get_scrape_job(job_id)
|
||||
if not job:
|
||||
return jsonify({'error': 'Job not found'}), 404
|
||||
|
||||
if job['status'] == 'running':
|
||||
return jsonify({'error': 'Cannot delete a running job — cancel it first'}), 400
|
||||
|
||||
conn = db._get_conn()
|
||||
conn.execute("DELETE FROM scrape_jobs WHERE id = ?", (job_id,))
|
||||
conn.commit()
|
||||
logger.info(f"Scraper job {job_id} deleted")
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
@app.route('/api/scraper/clear-failed', methods=['POST'])
|
||||
def api_scraper_clear_failed():
|
||||
"""Delete all failed and cancelled scrape jobs."""
|
||||
db = StatusDB()
|
||||
conn = db._get_conn()
|
||||
result = conn.execute("DELETE FROM scrape_jobs WHERE status IN ('failed', 'cancelled')")
|
||||
conn.commit()
|
||||
count = result.rowcount
|
||||
logger.info(f"Cleared {count} failed/cancelled scraper jobs")
|
||||
return jsonify({'ok': True, 'deleted': count})
|
||||
|
||||
|
||||
# ── Metrics API ──
|
||||
|
||||
@app.route('/api/metrics/history')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue