Files
kefu/deploy/knowledge-v3-field-fix-20260916/05-task-status.sh
T
2026-09-21 10:34:06 +08:00

13 lines
805 B
Bash

set -euo pipefail
docker exec -i im-admin-knowledge-worker-1 python - <<'PY'
import sqlite3,json,time
db=sqlite3.connect('file:/data/backend.db?mode=ro',uri=True);db.row_factory=sqlite3.Row
row=db.execute('SELECT * FROM knowledge_job WHERE id=?',('2a5c16ea559b4d5c890943fc0a541dba',)).fetchone()
options=json.loads(row['options_json']);state=json.loads(row['state_json'])
summary={k:row[k] for k in ('id','status','processed','created_items','model_calls','error')}
summary.update(pending_count=len(state.get('_pending',[])),model_format_fallbacks=options.get('model_format_fallbacks',0),
model_last_warning=options.get('model_last_warning',''),max_model_calls=options['max_model_calls'],
lease_seconds_left=max(0,round(row['lease_until']-time.time())))
print(json.dumps(summary,ensure_ascii=False))
PY