36 lines
903 B
Python
36 lines
903 B
Python
"""Re-queue all delivered (but not acked) triage rows so deliver_pending sends them again.
|
|
|
|
Usage:
|
|
python scripts/reset_triage_queue_to_queued.py
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
_API_ROOT = Path(__file__).resolve().parent.parent
|
|
if str(_API_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(_API_ROOT))
|
|
|
|
from sqlalchemy import update
|
|
|
|
from app.db import async_session
|
|
from app.models import ScoutTriageQueue
|
|
|
|
|
|
async def main() -> None:
|
|
async with async_session() as session:
|
|
result = await session.execute(
|
|
update(ScoutTriageQueue)
|
|
.where(ScoutTriageQueue.status == "delivered")
|
|
.values(status="queued", delivered_at=None)
|
|
)
|
|
await session.commit()
|
|
print(f"Reset {result.rowcount} rows from delivered → queued")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|