Skip to content

flex coding interview - #193

Open
Okaca wants to merge 3 commits into
Base360-AI:mainfrom
Okaca:main
Open

flex coding interview#193
Okaca wants to merge 3 commits into
Base360-AI:mainfrom
Okaca:main

Conversation

@Okaca

@Okaca Okaca commented Sep 7, 2026

Copy link
Copy Markdown

found bugs and fixed them

…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.
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