Add debugging support and improve revenue calculations - #140
Open
beki-kel wants to merge 1 commit into
Open
Conversation
beki-kel
commented
Jul 31, 2026
- Enhanced launch configuration for debugging backend and frontend in VS Code.
- Created DEBUGGING.md for a comprehensive debugging walkthrough.
- Updated dashboard.py to handle revenue lookup errors gracefully and ensure accurate revenue calculations using Decimal.
- Modified database_pool.py to use AsyncAdaptedQueuePool for async database connections.
- Adjusted cache.py to include tenant_id in cache keys for accurate revenue summaries.
- Improved reservations.py to calculate monthly revenue based on property timezone.
- Updated requirements.txt to specify sqlalchemy with asyncio support.
- Added docker-compose.debug.yml for debugging without rebuilding the image.
- Refined RevenueSummary.tsx to prevent floating-point precision issues.
- Introduced .gitignore to exclude local environment files and Vite cache. - Enhanced launch configuration for debugging backend and frontend in VS Code. - Created DEBUGGING.md for a comprehensive debugging walkthrough. - Updated dashboard.py to handle revenue lookup errors gracefully and ensure accurate revenue calculations using Decimal. - Modified database_pool.py to use AsyncAdaptedQueuePool for async database connections. - Adjusted cache.py to include tenant_id in cache keys for accurate revenue summaries. - Improved reservations.py to calculate monthly revenue based on property timezone. - Updated requirements.txt to specify sqlalchemy with asyncio support. - Added docker-compose.debug.yml for debugging without rebuilding the image. - Refined RevenueSummary.tsx to prevent floating-point precision issues.
There was a problem hiding this comment.
Pull request overview
This PR improves developer debugging ergonomics (VS Code + Docker attach workflow) and fixes correctness issues in revenue reporting by tightening tenant isolation, using async-safe SQLAlchemy pooling, and eliminating floating-point rounding drift.
Changes:
- Add end-to-end debugging docs and VS Code/Docker configurations (local launch + Docker attach).
- Fix revenue isolation/accuracy: tenant-scoped cache keys, DB-backed revenue queries, Decimal rounding on the backend, and timezone-correct month boundaries.
- Update async DB infrastructure: use
AsyncAdaptedQueuePooland correct session factory usage; update requirements to include SQLAlchemy asyncio extras.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/components/RevenueSummary.tsx | Removes redundant frontend re-rounding to avoid reintroducing float drift. |
| docker-compose.debug.yml | Adds a compose overlay to run backend under debugpy without rebuilding the image. |
| DEBUGGING.md | Provides a step-by-step debugging walkthrough and reproduction steps for prior bugs. |
| backend/requirements.txt | Switches to sqlalchemy[asyncio] to support async engine runtime requirements. |
| backend/app/services/reservations.py | Moves revenue computation to real DB queries; adds timezone-aware month boundaries and shared pool usage. |
| backend/app/services/cache.py | Fixes cache key to include tenant_id for isolation. |
| backend/app/core/database_pool.py | Corrects async engine pooling (AsyncAdaptedQueuePool) and session context manager behavior. |
| backend/app/api/v1/dashboard.py | Adds error handling (503 on lookup failure) and backend Decimal rounding to cents. |
| .vscode/launch.json | Adds/updates launch + attach configs and a full-stack compound debug config. |
| .gitignore | Ignores local venvs, bytecode, and Vite’s regenerated cache. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return "UTC" | ||
|
|
||
|
|
||
| async def calculate_monthly_revenue(property_id: str, tenant_id: str, month: int, year: int, db_session=None) -> Decimal: |
Comment on lines
+46
to
+47
| property_timezone = await _get_property_timezone(property_id, tenant_id) | ||
| local_tz = ZoneInfo(property_timezone) |
Comment on lines
15
to
18
| async def get_dashboard_summary( | ||
| property_id: str, | ||
| current_user: dict = Depends(get_current_user) | ||
| ) -> Dict[str, Any]: |
Comment on lines
+24
to
+27
| except Exception as e: | ||
| # Surface the outage instead of serving substitute figures: a revenue | ||
| # dashboard must never display numbers it cannot attribute to real data. | ||
| logger.error(f"Revenue lookup failed for {property_id} (tenant: {tenant_id}): {e}") |
Comment on lines
+9
to
+11
| ports: | ||
| - "8000:8000" | ||
| - "5678:5678" # debugpy |
Comment on lines
+12
to
+15
| command: > | ||
| sh -c "pip install --no-cache-dir debugpy && | ||
| python -m debugpy --listen 0.0.0.0:5678 | ||
| -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.