Update app.py
Browse files
app.py
CHANGED
|
@@ -199,10 +199,10 @@ async def get_sales_per_month(ano: int):
|
|
| 199 |
|
| 200 |
|
| 201 |
# Endpoint para obter as Vendas por Ano
|
| 202 |
-
@app.get("/sales_per_year
|
| 203 |
async def get_sales_per_year(ano: int):
|
| 204 |
with engine.connect() as conn:
|
| 205 |
-
results = conn.execute(text(f"SELECT * FROM sales_per_year
|
| 206 |
if results:
|
| 207 |
return [{"sales_year": row[0], "sales_per_year": row[1]} for row in results]
|
| 208 |
else:
|
|
@@ -238,10 +238,10 @@ async def get_revenue_per_month(ano: int):
|
|
| 238 |
|
| 239 |
|
| 240 |
# Endpoint para obter o Faturamento por Ano
|
| 241 |
-
@app.get("/revenue_per_year
|
| 242 |
async def get_revenue_per_year(ano: int):
|
| 243 |
with engine.connect() as conn:
|
| 244 |
-
results = conn.execute(text(f"SELECT * FROM revenue_per_year
|
| 245 |
if results:
|
| 246 |
return [
|
| 247 |
{"revenue_year": row[0], "revenue_per_year": row[1]} for row in results
|
|
|
|
| 199 |
|
| 200 |
|
| 201 |
# Endpoint para obter as Vendas por Ano
|
| 202 |
+
@app.get("/sales_per_year") # Adiciona o parâmetro 'ano'
|
| 203 |
async def get_sales_per_year(ano: int):
|
| 204 |
with engine.connect() as conn:
|
| 205 |
+
results = conn.execute(text(f"SELECT * FROM sales_per_year")).fetchall()
|
| 206 |
if results:
|
| 207 |
return [{"sales_year": row[0], "sales_per_year": row[1]} for row in results]
|
| 208 |
else:
|
|
|
|
| 238 |
|
| 239 |
|
| 240 |
# Endpoint para obter o Faturamento por Ano
|
| 241 |
+
@app.get("/revenue_per_year") # Adiciona o parâmetro 'ano'
|
| 242 |
async def get_revenue_per_year(ano: int):
|
| 243 |
with engine.connect() as conn:
|
| 244 |
+
results = conn.execute(text(f"SELECT * FROM revenue_per_year")).fetchall()
|
| 245 |
if results:
|
| 246 |
return [
|
| 247 |
{"revenue_year": row[0], "revenue_per_year": row[1]} for row in results
|