flex coding interview - #193
Open
Okaca wants to merge 3 commits into
Open
Conversation
…other company."
Cause: The Redis cache key was built from property_id alone (f"revenue:{property_id}"). Different tenants can have properties with the
same ID (e.g. both tenant-a and tenant-b have a prop-001 in database/seed.sql), so whichever tenant hit the endpoint first populated the cache, and the other tenant was served that cached data for up to 5 minutes.
Fix: Scoped the cache key to the tenant: f"revenue:{tenant_id}:{property_id}".
…ghtly off by a few cents." Cause: total_revenue_float = float(revenue_data['total']) converted an exact decimal string from the DB into a binary float, introducing rounding error. Seed data has a specific test case for this (333.333 + 333.333 + 333.334 should equal exactly 1000.000). Fix: Removed the float conversion — the total is now passed through as the original decimal string, preserving exact precision.
…et Properties) said March revenue didn't match their internal records. Cause: Month boundaries were computed as naive UTC datetimes (datetime(year, month, 1)), ignoring each property's own timezone (properties.timezone in the schema, e.g. Europe/Paris). check_in_date is stored as UTC. A reservation seeded specifically to expose this — res-tz-1, check-in 2024-02-29 23:30:00+00 — is 2024-03-01 00:30 local time in Paris (March, on the client's own calendar) but fell before the naive UTC March-1 boundary, so it was silently counted in February instead. Fix: The function now takes the property's property_timezone, builds the local month start/end with zoneinfo.ZoneInfo, and converts those boundaries to UTC before comparing against check_in_date — so bucketing matches the property owner's local calendar instead of the server's UTC clock.
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.
found bugs and fixed them