auto-sync: 2026-04-20 23:40:01
This commit is contained in:
@@ -646,12 +646,12 @@ def data_sources_page():
|
||||
return send_from_directory("/app/static", "data_sources.html")
|
||||
|
||||
|
||||
def _ds_where(args):
|
||||
def _ds_where(args, date_col="coverage_date"):
|
||||
clauses, params = [], []
|
||||
if args.get("date_from"):
|
||||
clauses.append("flight_date >= %s"); params.append(args["date_from"])
|
||||
clauses.append(f"{date_col} >= %s"); params.append(args["date_from"])
|
||||
if args.get("date_to"):
|
||||
clauses.append("flight_date <= %s"); params.append(args["date_to"])
|
||||
clauses.append(f"{date_col} <= %s"); params.append(args["date_to"])
|
||||
return (" AND ".join(clauses) if clauses else "1=1"), params
|
||||
|
||||
|
||||
@@ -693,7 +693,7 @@ def ds_coverage():
|
||||
@app.get("/api/data-sources/quality")
|
||||
def ds_quality():
|
||||
try:
|
||||
where, params = _ds_where(request.args)
|
||||
where, params = _ds_where(request.args, date_col="flight_date")
|
||||
q = query_one(
|
||||
f"""
|
||||
SELECT
|
||||
@@ -734,7 +734,7 @@ def ds_quality():
|
||||
@app.get("/api/data-sources/top-airlines")
|
||||
def ds_top_airlines():
|
||||
try:
|
||||
where, params = _ds_where(request.args)
|
||||
where, params = _ds_where(request.args, date_col="flight_date")
|
||||
rows = query(
|
||||
f"""
|
||||
SELECT airline_iata, COUNT(*) AS flight_count
|
||||
@@ -754,7 +754,7 @@ def ds_top_airlines():
|
||||
@app.get("/api/data-sources/top-routes")
|
||||
def ds_top_routes():
|
||||
try:
|
||||
where, params = _ds_where(request.args)
|
||||
where, params = _ds_where(request.args, date_col="flight_date")
|
||||
rows = query(
|
||||
f"""
|
||||
SELECT origin_iata, destination_iata, COUNT(*) AS flight_count
|
||||
@@ -776,7 +776,7 @@ def ds_top_routes():
|
||||
@app.get("/api/data-sources/airport-load")
|
||||
def ds_airport_load():
|
||||
try:
|
||||
where, params = _ds_where(request.args)
|
||||
where, params = _ds_where(request.args, date_col="flight_date")
|
||||
rows = query(
|
||||
f"""
|
||||
SELECT
|
||||
|
||||
Reference in New Issue
Block a user