fix: EIX scraping, LS endpoints, and premium Dashboard analytics
All checks were successful
Deployment / deploy-docker (push) Successful in 10s
All checks were successful
Deployment / deploy-docker (push) Successful in 10s
This commit is contained in:
@@ -59,7 +59,7 @@ async def get_summary():
|
||||
query = """
|
||||
select m.continent, m.country, count(*) as trade_count, sum(t.price * t.quantity) as total_volume
|
||||
from trades t
|
||||
join metadata m on t.isin = m.isin
|
||||
left join metadata m on t.isin = m.isin
|
||||
group by m.continent, m.country
|
||||
"""
|
||||
try:
|
||||
@@ -70,6 +70,24 @@ async def get_summary():
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.get("/api/comparison")
|
||||
async def get_comparison(days: int = 7):
|
||||
# Aggregated volume per exchange per day
|
||||
query = f"""
|
||||
select exchange, date_trunc('day', timestamp) as day, sum(price * quantity) as daily_volume, count(*) as trade_count
|
||||
from trades
|
||||
where timestamp > dateadd('d', -{days}, now())
|
||||
group by exchange, day
|
||||
order by day asc
|
||||
"""
|
||||
try:
|
||||
response = requests.get(f"http://{DB_HOST}:9000/exec", params={'query': query}, auth=DB_AUTH)
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
throw_http_error(response)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
def throw_http_error(res):
|
||||
raise HTTPException(status_code=res.status_code, detail=f"QuestDB error: {res.text}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user