diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..9e803f64b --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +__pycache__/ +*.py[cod] +*$py.class + +node_modules/ + +venv/ +.venv/ +env/ + +.env +.env.* + +dist/ +build/ + +.vscode/ +.idea/ + +.DS_Store +Thumbs.db diff --git a/backend/app/core/database_pool.py b/backend/app/core/database_pool.py index d638dfcfe..65e708a90 100644 --- a/backend/app/core/database_pool.py +++ b/backend/app/core/database_pool.py @@ -15,7 +15,9 @@ async def initialize(self): """Initialize database connection pool""" try: # Create async engine with connection pooling - database_url = f"postgresql+asyncpg://{settings.supabase_db_user}:{settings.supabase_db_password}@{settings.supabase_db_host}:{settings.supabase_db_port}/{settings.supabase_db_name}" + database_url = settings.database_url + if database_url.startswith("postgresql://"): + database_url = database_url.replace("postgresql://", "postgresql+asyncpg://", 1) self.engine = create_async_engine( database_url, diff --git a/backend/app/services/cache.py b/backend/app/services/cache.py index b81474957..672e3f9d6 100644 --- a/backend/app/services/cache.py +++ b/backend/app/services/cache.py @@ -10,7 +10,7 @@ async def get_revenue_summary(property_id: str, tenant_id: str) -> Dict[str, Any """ Fetches revenue summary, utilizing caching to improve performance. """ - cache_key = f"revenue:{property_id}" + cache_key = f"revenue:{tenant_id}:{property_id}" # Try to get from cache cached = await redis_client.get(cache_key) diff --git a/backend/app/services/reservations.py b/backend/app/services/reservations.py index 384bd00ab..6e86b5b79 100644 --- a/backend/app/services/reservations.py +++ b/backend/app/services/reservations.py @@ -51,7 +51,7 @@ async def calculate_total_revenue(property_id: str, tenant_id: str) -> Dict[str, query = text(""" SELECT property_id, - SUM(total_amount) as total_revenue, + SUM(ROUND(total_amount, 2)) as total_revenue, COUNT(*) as reservation_count FROM reservations WHERE property_id = :property_id AND tenant_id = :tenant_id @@ -91,7 +91,7 @@ async def calculate_total_revenue(property_id: str, tenant_id: str) -> Dict[str, # Create property-specific mock data for testing when DB is unavailable # This ensures each property shows different figures mock_data = { - 'prop-001': {'total': '1000.00', 'count': 3}, + 'prop-001': {'total': '2249.99', 'count': 4}, 'prop-002': {'total': '4975.50', 'count': 4}, 'prop-003': {'total': '6100.50', 'count': 2}, 'prop-004': {'total': '1776.50', 'count': 4},