26 lines
869 B
Bash
26 lines
869 B
Bash
|
|
#!/usr/bin/env bash
|
|||
|
|
set -euo pipefail
|
|||
|
|
|
|||
|
|
BACKLOG_PATH="${1:?backlog path required}"
|
|||
|
|
NOW_RAW="${LLM_NOW:-$(date '+%Y-%m-%d %H:%M')}"
|
|||
|
|
|
|||
|
|
python3 - <<'PY' "$BACKLOG_PATH" "$NOW_RAW"
|
|||
|
|
from pathlib import Path
|
|||
|
|
from datetime import datetime
|
|||
|
|
import re
|
|||
|
|
import sys
|
|||
|
|
|
|||
|
|
text = Path(sys.argv[1]).read_text(encoding='utf-8')
|
|||
|
|
now = datetime.strptime(sys.argv[2], '%Y-%m-%d %H:%M')
|
|||
|
|
match = re.search(r'## 当前未修复问题速查表(截至 ([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}))', text)
|
|||
|
|
if not match:
|
|||
|
|
print('missing current table timestamp', file=sys.stderr)
|
|||
|
|
raise SystemExit(1)
|
|||
|
|
seen = datetime.strptime(match.group(1), '%Y-%m-%d %H:%M')
|
|||
|
|
age_minutes = int((now - seen).total_seconds() // 60)
|
|||
|
|
if age_minutes > 180:
|
|||
|
|
print('stale current truth snapshot', file=sys.stderr)
|
|||
|
|
raise SystemExit(1)
|
|||
|
|
print(f'BACKLOG_FRESHNESS age_minutes={age_minutes} status=fresh')
|
|||
|
|
PY
|