From f88223d84fcc1589f32d6752499680416badebf6 Mon Sep 17 00:00:00 2001 From: Christophoros Date: Tue, 24 Mar 2026 16:23:25 +0200 Subject: [PATCH 1/2] make datePublished optional after apple does not always report it --- app/apple_fetch.py | 3 ++- app/dtos.py | 2 +- app/report.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/apple_fetch.py b/app/apple_fetch.py index 6b1e89f..102e946 100644 --- a/app/apple_fetch.py +++ b/app/apple_fetch.py @@ -36,7 +36,7 @@ def json(self): class AppleLocation(BaseModel): - date_published: int = Field(alias="datePublished") + date_published: int | None = Field(default=None, alias="datePublished") payload: str description: str id: str @@ -223,6 +223,7 @@ def merge_successful_responses(responses: list[AppleHTTPResponse]) -> ResponseDt return create_empty_response_dto() if len(responses) == 1: + logger.error(responses[0].json()) response_dto = ResponseDto(**responses[0].json()) logger.info("Single response with %d results", len(response_dto.results)) return response_dto diff --git a/app/dtos.py b/app/dtos.py index 7df4973..cf17d19 100644 --- a/app/dtos.py +++ b/app/dtos.py @@ -15,7 +15,7 @@ class Report(BaseModel): class EnrichedReport(Report): device_id: str timestamp: int - date_published: int + date_published: int | None = None description: str diff --git a/app/report.py b/app/report.py index 07b39ce..3ec8266 100644 --- a/app/report.py +++ b/app/report.py @@ -76,7 +76,7 @@ def create_reports(locations: list[AppleLocation], devices: list[BeamerDevice]): **report.model_dump(), device_id=device.id, timestamp=timestamp, - date_published=location.date_published, + date_published=location.date_published if location.date_published is not None else timestamp, description=location.description, ) device.report = enriched_report From b13de51bc36e27d31b7587162f5a4b7d149f60fe Mon Sep 17 00:00:00 2001 From: Christophoros Date: Tue, 24 Mar 2026 16:29:02 +0200 Subject: [PATCH 2/2] remove debug log --- app/apple_fetch.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/apple_fetch.py b/app/apple_fetch.py index 102e946..f263ff5 100644 --- a/app/apple_fetch.py +++ b/app/apple_fetch.py @@ -223,7 +223,6 @@ def merge_successful_responses(responses: list[AppleHTTPResponse]) -> ResponseDt return create_empty_response_dto() if len(responses) == 1: - logger.error(responses[0].json()) response_dto = ResponseDto(**responses[0].json()) logger.info("Single response with %d results", len(response_dto.results)) return response_dto