Refactor logging messages for clarity, update datetime handling to us…#10
Refactor logging messages for clarity, update datetime handling to us…#10mpatrikios wants to merge 3 commits into
Conversation
…e timezone-aware methods, and add Google Cloud Storage utility functions
There was a problem hiding this comment.
Pull request overview
This pull request refactors logging throughout the codebase for clarity by removing emoji characters and reducing verbose debug logging, updates datetime handling to use timezone-aware methods (datetime.now(timezone.utc) instead of datetime.utcnow()), and introduces a new centralized Google Cloud Storage utility module (app/core/gcs.py) to eliminate code duplication and improve performance through singleton pattern usage.
Changes:
- Removed emoji characters from all logging messages in backend Python code and shell scripts for cleaner, more professional logs
- Refactored Google Cloud Storage client initialization into a shared utility module with singleton pattern to avoid 150-200ms overhead per initialization
- Updated datetime handling in models to use timezone-aware methods (
datetime.now(timezone.utc)) for consistency - Cleaned up frontend JavaScript console logging by removing debug statements and emoji characters
- Refactored download/upload endpoints to use the new GCS utility module and database-driven export tracking for multi-instance Cloud Run compatibility
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/static/js/state-manager.js | Removed excessive console.log statements for token refresh and job completion operations |
| frontend/static/js/photo-processor.js | Removed emoji characters from console.error messages |
| frontend/static/js/analytics-dashboard.js | Removed verbose debug logging and cleaned up conditional initialization logic |
| frontend/index.html | Updated tagline and added styling to emphasize "Sort" in mission statement |
| backend/main.py | Removed emoji characters from all logging statements and cleaned up import of removed cleanup_old_jobs function |
| backend/entrypoint.sh | Removed emoji characters from shell script echo statements |
| backend/app/services/detector.py | Removed emoji characters from logging, moved GCS client singleton to shared utility module, changed some logger.info calls to logger.debug for performance-related logs |
| backend/app/models/usage.py | Updated datetime methods from datetime.utcnow() to datetime.now(timezone.utc) for timezone awareness |
| backend/app/models/processing.py | Updated datetime methods from datetime.utcnow() to datetime.now(timezone.utc) for timezone awareness |
| backend/app/core/gcs.py | New shared utility module for Google Cloud Storage operations with singleton client pattern and signed URL generation |
| backend/app/core/config.py | Removed emoji characters from logging statements |
| backend/app/api/upload.py | Refactored to use new gcs.py utility module instead of duplicated GCS client initialization |
| backend/app/api/process_tasks.py | Removed emoji characters from logging, removed unused cleanup_old_jobs function, changed many logger.info calls to logger.debug |
| backend/app/api/download.py | Major refactor to use database-driven export tracking for multi-instance compatibility, use gcs.py utilities, and download photos directly from GCS during export creation |
| backend/app/api/direct_upload.py | Refactored to use new gcs.py utility module instead of duplicated GCS client initialization |
| .firebase/hosting.ZnJvbnRlbmQ.cache | Updated Firebase cache hashes for modified frontend files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from datetime import datetime, timedelta | ||
| if hasattr(job_data["job"], 'created_at'): | ||
| time_elapsed = datetime.utcnow() - job_data["job"].created_at |
There was a problem hiding this comment.
This local import statement imports datetime and timedelta, but the code on line 561 uses datetime.utcnow() which is inconsistent with the PR's goal of updating to timezone-aware datetime methods. This should import timezone as well and use datetime.now(timezone.utc) on line 561 for consistency with other files in this PR (usage.py, processing.py).
| from datetime import datetime, timedelta | |
| if hasattr(job_data["job"], 'created_at'): | |
| time_elapsed = datetime.utcnow() - job_data["job"].created_at | |
| from datetime import datetime, timedelta, timezone | |
| if hasattr(job_data["job"], 'created_at'): | |
| time_elapsed = datetime.now(timezone.utc) - job_data["job"].created_at |
| # Update ExportDB record with success status | ||
| export_record.status = ExportStatus.READY | ||
| export_record.file_size_bytes = total_size | ||
| export_record.completed_at = datetime.utcnow() |
There was a problem hiding this comment.
This line uses datetime.utcnow() which is inconsistent with the PR's goal of updating datetime handling to use timezone-aware methods. This should be changed to datetime.now(timezone.utc) to match the pattern used in usage.py and processing.py. Additionally, timezone needs to be imported from the datetime module.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…e timezone-aware methods, and add Google Cloud Storage utility functions