From 996b9d107273d1f0309aeae77470abf49c41d6f0 Mon Sep 17 00:00:00 2001 From: Tudor Sitaru Date: Mon, 5 Jan 2026 13:25:15 +0000 Subject: [PATCH] Reworked snapshot template output --- src/snapshot_downloader.py | 39 ++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/snapshot_downloader.py b/src/snapshot_downloader.py index 8fbe820..d12ad01 100644 --- a/src/snapshot_downloader.py +++ b/src/snapshot_downloader.py @@ -175,8 +175,7 @@ class SnapshotDownloader: params["cursor"] = cursor # Add type IDs - API expects typeIDs[]=15 format - for type_id in type_ids: - params["typeIDs[]"] = type_id + params["typeIDs[]"] = type_ids # Build URL with parameters query_string = urlencode(params, doseq=True) @@ -192,6 +191,13 @@ class SnapshotDownloader: response.raise_for_status() data = await response.json() + # Log API response summary + posts_count = len(data.get("posts", [])) + has_cursor = bool(data.get("cursor")) + self.logger.info( + f"API Response: status={response.status}, posts={posts_count}, has_next_page={has_cursor}" + ) + # Print detailed response information for debugging if enabled if self.debug_mode: page_info = f"cursor: {cursor[:20]}..." if cursor else "first page" @@ -202,11 +208,9 @@ class SnapshotDownloader: print( f"Response Keys: {list(data.keys()) if isinstance(data, dict) else 'Not a dict'}" ) - print(f"Posts count: {len(data.get('posts', []))}") + print(f"Posts count: {posts_count}") print(f"Cursor: {data.get('cursor', 'None')}") - if ( - len(data.get("posts", [])) <= 3 - ): # Only print full data if few posts + if posts_count <= 3: # Only print full data if few posts print("Full Response Data:") print(json.dumps(data, indent=2, default=str)) print("=" * 50) @@ -282,6 +286,22 @@ class SnapshotDownloader: self.logger.info( f"Page {page_count}: {len(snapshots)} snapshots (total: {len(all_snapshots)})" ) + + # Log sample of retrieved snapshots for visibility + if snapshots: + first = snapshots[0] + child_name = first.get("child", {}).get("forename", "Unknown") if first.get("child") else "Unknown" + start_time = first.get("startTime", "Unknown")[:10] if first.get("startTime") else "Unknown" + self.logger.info( + f" → First snapshot: child={child_name}, date={start_time}, id={first.get('id', 'N/A')[:8]}..." + ) + if len(snapshots) > 1: + last = snapshots[-1] + child_name = last.get("child", {}).get("forename", "Unknown") if last.get("child") else "Unknown" + start_time = last.get("startTime", "Unknown")[:10] if last.get("startTime") else "Unknown" + self.logger.info( + f" → Last snapshot: child={child_name}, date={start_time}, id={last.get('id', 'N/A')[:8]}..." + ) # If no cursor returned, we've reached the end if not new_cursor: @@ -296,6 +316,13 @@ class SnapshotDownloader: break self.logger.info(f"Total snapshots fetched: {len(all_snapshots)}") + + # Log summary of date range covered + if all_snapshots: + dates = [s.get("startTime", "")[:10] for s in all_snapshots if s.get("startTime")] + if dates: + self.logger.info(f"Date range in results: {min(dates)} to {max(dates)}") + return all_snapshots async def format_snapshot_html(