Repository navigation
Conversation
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.
Summary
Investigated the three issues reported on the revenue dashboard and found six root causes. Each fix is in its own atomic commit.
17ab196,98841be,ca9dc42f51a47drevenue:{property_id}, shared across tenants882625bfloatand rounded client-side withMath.round6bc09900faa807,2e53fedX-Simulated-Tenantdebug header5ea3a7dChanges
1. Database connectivity (
database_pool.py,requirements.txt)DATABASE_URL(thesupabase_db_*settings it read don't exist).QueuePool, which is invalid for async engines.get_sessionsync soasync with db_pool.get_session()receives a session, not a coroutine.initialize()idempotent.sqlalchemy[asyncio]sogreenletis present on ARM images.2. Remove the mock fallback (
reservations.py,dashboard.py)mock_datafallback. DB failures now return503with the error logged, instead of fabricated financial figures.3. Tenant-scoped cache key (
cache.py)revenue:{property_id}→revenue:{tenant_id}:{property_id}.prop-001exists for both tenants, so whoever loaded it first had their data served to the other tenant for 5 minutes.4. Money precision (
reservations.py,dashboard.py,RevenueSummary.tsx)Decimal+ROUND_HALF_UPin the backend.float. The frontend only formats it.5. Timezone-aware monthly revenue (
reservations.py)calculate_monthly_revenuenow takestenant_id, joinsproperties, and buckets check-ins withcheck_in_date AT TIME ZONE p.timezone.0.6. Tenant-scoped property list (
dashboard.py,Dashboard.tsx,secureApi.ts,RevenueSummary.tsx)GET /api/v1/dashboard/properties, with the tenant resolved from the auth token only. Returns403if the tenant can't be resolved.X-Simulated-Tenantheader. The tenant must never come from the client.Verification
/dashboard/summaryreturns 200 for every property.revenue:tenant-a:prop-001,revenue:tenant-b:prop-001).tsc --noEmitpasses for the changed frontend files.Deploy notes
sqlalchemy[asyncio]dependency).revenue:{property_id}keys may hold cross-tenant data.Follow-ups (out of scope)
/dashboard/summaryshould return 404 for a property outside the caller's tenant instead of0.00.default_tenantfallback in/dashboard/summaryso it fails closed.properties/reservationsbut has no policies.