from fastapi import FastAPI, HTTPException,Query from supabase import create_client, Client import os app = FastAPI() url: str = os.getenv('SUPABASE_URL') key: str = os.getenv('SUPABASE_KEY') supabase: Client = create_client(url, key) @app.get('/get_hotel_data') async def get_hotel_data(hushh_id:str): hotel_brand_frequency = {} result = {} resp = supabase.table("receipt_radar_structured_data_duplicate").select("brand,message_id,company,logo").eq("brand_category","Hospitality").execute() for ds in resp.data: if ds.get('company'): result[ds.get('brand')] = {"message_id":ds.get('message_id'),"domain":ds.get('company'),"hotel_logo":ds.get('logo')} # if arrival_city: if ds.get('brand') in hotel_brand_frequency: hotel_brand_frequency[ds.get('brand')] += 1 else: hotel_brand_frequency[ds.get('brand')] = 1 sorted_hotel_brand_frequency = dict( sorted(hotel_brand_frequency.items(), key=lambda item: item[1], reverse=True) ) result['hotel_brand_frequency'] = sorted_hotel_brand_frequency return result