forked from Rockachopa/Timmy-time-dashboard
This commit is contained in:
@@ -30,7 +30,7 @@ IDLE_STATE_FILE = REPO_ROOT / ".loop" / "idle_state.json"
|
||||
CYCLE_RESULT_FILE = REPO_ROOT / ".loop" / "cycle_result.json"
|
||||
TOKEN_FILE = Path.home() / ".hermes" / "gitea_token"
|
||||
|
||||
GITEA_API = os.environ.get("GITEA_API", "http://localhost:3000/api/v1")
|
||||
GITEA_API = os.environ.get("GITEA_API", "http://143.198.27.163:3000/api/v1")
|
||||
REPO_SLUG = os.environ.get("REPO_SLUG", "rockachopa/Timmy-time-dashboard")
|
||||
|
||||
# Default cycle duration in seconds (5 min); stale threshold = 2× this
|
||||
|
||||
@@ -20,7 +20,7 @@ from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
# ── Config ──────────────────────────────────────────────────────────────
|
||||
GITEA_API = os.environ.get("GITEA_API", "http://localhost:3000/api/v1")
|
||||
GITEA_API = os.environ.get("GITEA_API", "http://143.198.27.163:3000/api/v1")
|
||||
REPO_SLUG = os.environ.get("REPO_SLUG", "rockachopa/Timmy-time-dashboard")
|
||||
TOKEN_FILE = Path.home() / ".hermes" / "gitea_token"
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
@@ -327,7 +327,31 @@ def run_triage() -> list[dict]:
|
||||
not_ready = [s for s in scored if not s["ready"]]
|
||||
|
||||
QUEUE_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
QUEUE_FILE.write_text(json.dumps(ready, indent=2) + "\n")
|
||||
backup_file = QUEUE_FILE.with_suffix(".json.bak")
|
||||
|
||||
# Backup existing queue before overwriting
|
||||
if QUEUE_FILE.exists():
|
||||
try:
|
||||
backup_file.write_text(QUEUE_FILE.read_text())
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# Write and validate
|
||||
queue_json = json.dumps(ready, indent=2) + "\n"
|
||||
QUEUE_FILE.write_text(queue_json)
|
||||
|
||||
# Validate by re-reading — restore backup on corruption
|
||||
try:
|
||||
validated = json.loads(QUEUE_FILE.read_text())
|
||||
if not isinstance(validated, list):
|
||||
raise ValueError("queue.json is not a list")
|
||||
except (json.JSONDecodeError, ValueError) as e:
|
||||
print(f"[triage] ERROR: queue.json validation failed: {e}", file=sys.stderr)
|
||||
if backup_file.exists():
|
||||
print("[triage] Restoring from backup", file=sys.stderr)
|
||||
QUEUE_FILE.write_text(backup_file.read_text())
|
||||
else:
|
||||
QUEUE_FILE.write_text("[]\n")
|
||||
|
||||
# Write retro entry
|
||||
retro_entry = {
|
||||
|
||||
Reference in New Issue
Block a user