Files
devplacepy/devplacepy/routers/sync/export.py
T
retoorandClaude Sonnet 5.5 02ab747cd0 Code Farm: per-plot auto-replant pause and crop-lock check; community sync and node work
Continuous Delivery could never be turned off once a crop was planted. Add a
one-shot per-plot "stop after harvest" flag (POST /game/plot/stop, Devii tool
game_plot_stop, game_plots.stop_after_harvest), cleared by the next plant,
autoreplant claim or Refactor. Autoreplant now also respects crop locks through
the shared _crop_lock predicate. Plan and measurements in happyplanting.md.

Also includes the pending community sync, node network and related work in the
tree; the full suite passed (4999) with all of it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 02:23:43 +02:00

53 lines
1.8 KiB
Python

# retoor <retoor@molodetz.nl>
from fastapi import APIRouter, Depends, Request
from fastapi.responses import JSONResponse
from devplacepy.responses import json_error
from devplacepy.routers.sync._shared import NO_STORE, require_sync_caller
from devplacepy.schemas.sync import SyncExportOut
from devplacepy.services.audit import record as audit
from devplacepy.services.sync.exporter import ExportError, export_page
from devplacepy.services.sync.gate import sync_enabled
from devplacepy.services.sync.normalize import instant_iso
from devplacepy.services.sync.spec import EXPORT_KINDS, LIMITS
router = APIRouter()
@router.get("/export/{kind}")
async def sync_export(
request: Request,
kind: str,
user: dict = Depends(require_sync_caller),
since: str = "",
cursor: str = "",
limit: int = LIMITS.export_page_size,
):
if not sync_enabled():
return json_error(503, "Community sync is disabled")
if kind not in EXPORT_KINDS:
return json_error(404, f"{kind} cannot be exported", reason="not_exportable", exportable=list(EXPORT_KINDS))
try:
floor = instant_iso(since) if since else ""
page = export_page(kind, floor, cursor, limit)
except (ExportError, ValueError) as exc:
return json_error(400, str(exc))
audit.record(
request,
"sync.export",
user=user,
target_type="sync",
target_label=kind,
metadata={"kind": kind, "count": len(page.records), "since": floor, "has_more": page.has_more},
summary=f"{user['username']} exported {len(page.records)} {kind}",
)
body = SyncExportOut(
kind=kind,
count=len(page.records),
has_more=page.has_more,
next_cursor=page.next_cursor,
records=page.records,
)
return JSONResponse(body.model_dump(mode="json"), headers=NO_STORE)