Files
devplacepy/devplacepy/services/sync/batch.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

39 lines
1.4 KiB
Python

# retoor <retoor@molodetz.nl>
from __future__ import annotations
from collections import Counter
from devplacepy.schemas.sync import SyncBatchOut, SyncRecordResultOut
from devplacepy.services.sync.pending import PendingQueue
from devplacepy.services.sync.processors import PROCESSORS
from devplacepy.services.sync.records import SyncBatchForm
from devplacepy.services.sync.spec import STATUSES
class BatchRunner:
def __init__(self, kind: str, *, request=None, humanize: bool = False):
self.kind = kind
self.request = request
self.humanize = humanize
def run(self, data: SyncBatchForm) -> SyncBatchOut:
processor = PROCESSORS[self.kind](
data.origin, dry_run=data.dry_run, request=self.request, humanize=self.humanize
)
results = [
SyncRecordResultOut(**vars(processor.process(index, raw)))
for index, raw in enumerate(data.records)
]
tally = Counter(result.status for result in results)
released = {} if data.dry_run else dict(PendingQueue().release(data.origin))
return SyncBatchOut(
origin=data.origin,
kind=self.kind,
dry_run=data.dry_run,
total=len(results),
counts={status: tally.get(status, 0) for status in STATUSES},
results=results,
released=released,
)