Skip to content

Debugging assignment - #138

Open
aplainzetakind wants to merge 3 commits into
Base360-AI:mainfrom
aplainzetakind:assignment
Open

Debugging assignment#138
aplainzetakind wants to merge 3 commits into
Base360-AI:mainfrom
aplainzetakind:assignment

Conversation

@aplainzetakind

Copy link
Copy Markdown

No description provided.

aplainzetakind 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant