Spaces:
Sleeping
Sleeping
from fastapi import FastAPI, HTTPException,Query | |
from supabase import create_client, Client | |
app = FastAPI() | |
url: str = os.getenv('SUPABASE_URL') | |
key: str = os.getenv('SUPABASE_KEY') | |
supabase: Client = create_client(url, key) | |
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","Travel").execute() | |
for ds in resp.data: | |
if ds.get('brand'): | |
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 | |
result['hotel_brand_frequency'] = hotel_brand_frequency | |
return result | |