Zo doen wijdat in oost

This commit is contained in:
2026-10-16 07:20:44 +02:00
parent 25d9cb1c7d
commit 6f80a820da
229 changed files with 23894 additions and 74 deletions
+34
View File
@@ -0,0 +1,34 @@
# retoor <retoor@molodetz.nl>
from __future__ import annotations
from collections import Counter
from devplacepy.schemas.sync import SyncBatchOut, SyncRecordResultOut
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):
self.kind = kind
self.request = request
def run(self, data: SyncBatchForm) -> SyncBatchOut:
processor = PROCESSORS[self.kind](
data.origin, dry_run=data.dry_run, request=self.request
)
results = [
SyncRecordResultOut(**vars(processor.process(index, raw)))
for index, raw in enumerate(data.records)
]
tally = Counter(result.status for result in results)
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,
)