File size: 1,161 Bytes
5db7441
 
72ffc8f
5db7441
 
 
 
 
 
 
 
 
 
 
 
871cd6a
5db7441
cd0443c
5db7441
 
 
 
 
 
f3145ca
 
 
5db7441
f3145ca
5db7441
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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