feat(skill): cover full API — projects, delete, health, all WorkCreate fields
All checks were successful
ci / build-test-push (push) Successful in 1m26s
All checks were successful
ci / build-test-push (push) Successful in 1m26s
This commit is contained in:
@@ -1,35 +1,33 @@
|
||||
#!/bin/bash
|
||||
# wq_stale_check — find in_progress items older than timeout, mark blocked
|
||||
|
||||
wq_stale_check() {
|
||||
local timeout_minutes="${1:-30}"
|
||||
API_URL="${WORK_QUEUE_API_URL:-}"
|
||||
[[ -z "$API_URL" ]] && API_URL=$(cat ~/.config/work_queue_api_url 2>/dev/null || echo "")
|
||||
[[ -z "$API_URL" ]] && { echo "Error: WORK_QUEUE_API_URL not set" >&2; exit 1; }
|
||||
|
||||
local items
|
||||
items=$(curl -sf "$API_URL/work?status=in_progress" | jq -r '.[] | @json' 2>/dev/null || echo "")
|
||||
timeout_minutes="${1:-30}"
|
||||
|
||||
if [[ -z "$items" ]]; then
|
||||
echo "No in_progress items found."
|
||||
return 0
|
||||
items=$(curl -sf "$API_URL/work?status=in_progress" | jq -r '.[] | @json' 2>/dev/null || echo "")
|
||||
|
||||
[[ -z "$items" ]] && { echo "No in_progress items found."; exit 0; }
|
||||
|
||||
count=0
|
||||
now_ts=$(date -u +%s)
|
||||
|
||||
while IFS= read -r item; do
|
||||
[[ -z "$item" ]] && continue
|
||||
work_id=$(echo "$item" | jq -r '.id')
|
||||
updated_at=$(echo "$item" | jq -r '.updated_at')
|
||||
agent=$(echo "$item" | jq -r '.assigned_agent')
|
||||
age_minutes=$(( (now_ts - $(date -u -d "$updated_at" +%s 2>/dev/null || echo "$now_ts")) / 60 ))
|
||||
|
||||
if [[ "$age_minutes" -gt "$timeout_minutes" ]]; then
|
||||
echo "Stale: $work_id ($agent, ${age_minutes}m old) — marking blocked"
|
||||
curl -sf -X PATCH "$API_URL/work/$work_id" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"status\":\"blocked\",\"notes\":\"Auto-blocked: stale for ${age_minutes} minutes (>$timeout_minutes)\"}" > /dev/null
|
||||
count=$((count + 1))
|
||||
fi
|
||||
done <<< "$items"
|
||||
|
||||
local count=0
|
||||
now_ts=$(date -u +%s)
|
||||
|
||||
while IFS= read -r item; do
|
||||
[[ -z "$item" ]] && continue
|
||||
work_id=$(echo "$item" | jq -r '.id')
|
||||
updated_at=$(echo "$item" | jq -r '.updated_at')
|
||||
agent=$(echo "$item" | jq -r '.assigned_agent')
|
||||
age_minutes=$(( (now_ts - $(date -u -d "$updated_at" +%s 2>/dev/null || echo "$now_ts")) / 60 ))
|
||||
|
||||
if [[ "$age_minutes" -gt "$timeout_minutes" ]]; then
|
||||
echo "Stale: $work_id ($agent, ${age_minutes}m old) — marking blocked"
|
||||
curl -sf -X PATCH "$API_URL/work/$work_id" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"status\":\"blocked\",\"notes\":\"Auto-blocked: stale for ${age_minutes} minutes (>$timeout_minutes)\"}" | jq -r '.id' > /dev/null
|
||||
count=$((count + 1))
|
||||
fi
|
||||
done <<< "$items"
|
||||
|
||||
echo "Stale check complete: $count items marked blocked."
|
||||
}
|
||||
echo "Stale check complete: $count items marked blocked."
|
||||
|
||||
Reference in New Issue
Block a user