Debugging assignment - #138
Open
aplainzetakind wants to merge 3 commits into
Open
Conversation
added 3 commits
July 31, 2026 16:48
- database_url was built from non-existent supabase_* settings, causing init to crash and every request to fall back to mock data. Read settings.database_url directly and coerce scheme to asyncpg. - DatabasePool was recreated per request in reservations service. Switch to the shared global singleton. - Initialise pool in app lifespan; align get_session (sync) with async-with usage. - Add backend test for the fixed code path; include pytest and pytest-asyncio in requirements.
- Frontend Dashboard rendered a hardcoded PROPERTIES list shared across clients. Properties are not unique across tenants; another tenant's property names and IDs were visible in the dropdown. Replace with API fetch from /api/v1/properties, which filters by authenticated tenant. - Cache key in services/cache was keyed only on property_id. Two tenants with a property sharing the same id would receive each other's cached revenue summary. Include tenant_id in the key. - Stricten selectedProperty state to string | null and drop the hardcoded propertyId default in RevenueSummary (incidental: no falsy-sentinel bugs, and the magic default would leak another tenant's data if the parent guard ever regressed).
- Frontend displayed totals via Math.round(x * 100) / 100 on a float parsed from the DB. A halfway third-decimal value like .555 with an internal float representation of .5549... was rounded down by Math.round's halfway-to-even behaviour, producing values a few cents below the true sum. - reservations.py quantises the SUM(total_amount) to 2 decimal places with ROUND_HALF_UP so .5 always rounds up, regardless of how the float is laid out in memory. - dashboard.py drops the float() round-trip; pass the canonical 2dp string straight through. - RevenueSummary types total_revenue as string, parses via parseFloat (preserves precision from a string source), and removes the "Precision Mismatch Detected" warning UI that no longer reflects reality. - Test assertion updated to match the 2dp output.
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.
No description provided.