Skip to content
Snippets Groups Projects

improve front

1 file
+ 1
0
Compare changes
  • Side-by-side
  • Inline
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from datetime import timedelta
from typing import List
from db import crud
from db import schemas, crud
from db.database import get_db
router = APIRouter(prefix="/api", tags=["stats"])
@router.get('/{place}/waiting_time', response_model=timedelta)
@router.get('/{place}/waiting_time', response_model=tuple)
async def waiting_time(place: str, db: Session = Depends(get_db)):
return crud.get_waiting_time(place, db)
@router.get('/{place}/stats/{day}/{min_time_hour}/{min_time_mn}/{max_time_hour}/{max_time_mn}/{interval}', response_model=list)
async def stats(place: str, day: int, min_time_hour: int, min_time_mn: int,
max_time_hour: int, max_time_mn: int, interval: timedelta, db: Session = Depends(get_db)):
return crud.get_stats(place, day, min_time_hour, min_time_mn, max_time_hour, max_time_mn, interval, db)
@router.get('/{place}/stats/avg_graph', response_model=list)
async def stats(place: str, db: Session = Depends(get_db)):
return crud.get_avg_graph(place, db)
@router.get('/{place}/stats/current_graph', response_model=list)
async def stats(place: str, db: Session = Depends(get_db)):
return crud.get_current_graph(place, db)
@router.get('/{place}/opening_hours', response_model=List[schemas.OpeningHours])
async def get_opening_hours(place: str, db: Session = Depends(get_db)):
return crud.get_opening_hours(place, db)
@router.get('/{place}/opening_hours/{day}/{timeslot}', response_model=List[schemas.OpeningHours])
async def get_timeslot(place: str, day: int, timeslot: bool, db: Session = Depends(get_db)):
return crud.get_timeslot(place, day, timeslot, db)
@router.post('/opening_hours', response_model=schemas.OpeningHours)
async def create_opening_hours(opening_hours: schemas.OpeningHoursBase, db: Session = Depends(get_db)):
return crud.create_opening_hours(opening_hours, db)
@router.delete('/opening_hours/{id}', response_model=None)
async def delete_opening_hours(id: int, db: Session = Depends(get_db)):
return crud.delete_opening_hours(id, db)
@router.get('/restaurants', response_model=List[dict])
async def get_restaurants(db: Session = Depends(get_db)):
return crud.get_restaurants(db)
Loading