Fix tenant cache leak, dead DB pool/mock fallback, timezone month bounds, decimal money - #171
Open
alpha-magic wants to merge 4 commits into
Open
Fix tenant cache leak, dead DB pool/mock fallback, timezone month bounds, decimal money#171alpha-magic wants to merge 4 commits into
alpha-magic wants to merge 4 commits into
Conversation
…ard-coded property names and fabricated trend badges from the dashboard. Cleaned up timezone validation logic and adjusted revenue calculations to ensure accurate financial reporting. Updated tests to reflect these changes.
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
Full write-up in
FINDINGS.md. Root causes fixed:revenue:{property_id}; property IDs are only unique per tenant (both tenants ownprop-001). Key is now tenant- and period-scoped, and the cached payload's tenant is verified before serving.settings.supabase_db_*fields andget_sessionwas anasync defused as a context manager; every request fell into a hard-coded mock table (prop-001 = 1000.00for any tenant). Pool now usesDATABASE_URL, single shared pool, mock fallback removed → DB errors surface as 503.2024-02-29 23:30 UTCis 1 March in Europe/Paris; month bounds are now evaluated in the property's timezone (AT TIME ZONE properties.timezone), andmonth/yearare wired into the endpoint and UI.float()onNUMERIC(10,3)plus a second rounding in the UI drifted cents. Sum in SQL, round once (ROUND_HALF_UP), serialise as string./dashboard/propertiesendpoint; fabricated badge removed.default_tenantfallback (403), tenant resolver reads the signed JWT claim and no longer defaults unknown users totenant-a,X-Simulated-Tenantheader removed, foreign property → 404.Verification
prop-001: 2250.00 / 4 (March 2024 in Paris: 2250.00; Feb: 0.00)prop-001: 0.00 / 0 (was showing Sunset's 1000.00 / 3)revenue:v2:{tenant}:{property}:{period}cd backend && python -m pytest -q→ 9 passedLoom
loom video