feat: expose safe moderation provenance
This commit is contained in:
+15
-1
@@ -162,15 +162,29 @@ def admin_start_official_import(db: Db, _: Annotated[str, Depends(_admin)]) -> O
|
||||
|
||||
|
||||
def _external_out(item: ExternalObservation) -> ExternalObservationOut:
|
||||
allowed_payload = {
|
||||
key: value for key, value in (item.payload or {}).items()
|
||||
if key in {
|
||||
"bait", "fishing_method", "rig_type", "retrieve_method", "retrieve_speed",
|
||||
"player_name", "published_at", "region", "category",
|
||||
} and (value is None or isinstance(value, (str, int, float, bool)))
|
||||
}
|
||||
missing_fields = []
|
||||
if item.x is None or item.y is None:
|
||||
missing_fields.append("coordinates")
|
||||
if item.weight_g is None:
|
||||
missing_fields.append("weight_g")
|
||||
return ExternalObservationOut(
|
||||
id=item.id, source_system=item.source_system, source_external_id=item.source_external_id,
|
||||
source_url=item.source_url, fish_name=item.fish_name, fish_external_id=item.fish_external_id,
|
||||
waterbody_name=item.waterbody_name, waterbody_external_id=item.waterbody_external_id,
|
||||
x=item.x, y=item.y, weight_g=item.weight_g, published_at=item.published_at,
|
||||
last_seen_at=item.last_seen_at, status=item.status,
|
||||
first_seen_at=item.first_seen_at, last_seen_at=item.last_seen_at, reviewed_at=item.reviewed_at,
|
||||
status=item.status,
|
||||
fish_slug=item.fish.slug if item.fish else None,
|
||||
waterbody_slug=item.waterbody.slug if item.waterbody else None,
|
||||
catch_report_id=item.catch_report_id, review_note=item.review_note,
|
||||
missing_fields=missing_fields, source_payload=allowed_payload,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -226,12 +226,16 @@ class ExternalObservationOut(BaseModel):
|
||||
y: int | None
|
||||
weight_g: int | None
|
||||
published_at: datetime | None
|
||||
first_seen_at: datetime
|
||||
last_seen_at: datetime
|
||||
reviewed_at: datetime | None
|
||||
status: str
|
||||
fish_slug: str | None
|
||||
waterbody_slug: str | None
|
||||
catch_report_id: UUID | None
|
||||
review_note: str | None
|
||||
missing_fields: list[str]
|
||||
source_payload: dict[str, str | int | float | bool | None]
|
||||
|
||||
|
||||
class ExternalObservationMapping(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user