diff --git a/backend/db/crud.py b/backend/db/crud.py index b90c047440b3ceabd6dbbaacfe6a1cb4ec24ad56..45f099a6f81d551df76bbc4645d2c189f422467e 100644 --- a/backend/db/crud.py +++ b/backend/db/crud.py @@ -7,7 +7,8 @@ from db import models, schemas def get_records(place: str, db: Session): """ Get all the records for the given place """ - records = db.query(models.Records).filter(models.Records.place == place).order_by(models.Records.date.desc()).all() + records = db.query(models.Records).filter( + models.Records.place == place).order_by(models.Records.date.desc()).all() return records @@ -17,4 +18,4 @@ def create_record(new_record: schemas.RecordBase, db: Session): db.add(db_record) db.commit() db.refresh(db_record) - return db_record \ No newline at end of file + return db_record diff --git a/backend/db/database.py b/backend/db/database.py index 6f995021c61b44f28e3d48520cfa0a1a4e0ca536..24d0618c30abfffc5d88776c5eec1507c84bc7ca 100644 --- a/backend/db/database.py +++ b/backend/db/database.py @@ -15,4 +15,3 @@ engine = create_engine(SQLALCHEMY_DATABASE_URL) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) Base = declarative_base() - diff --git a/backend/db/models.py b/backend/db/models.py index 55820de9e561fe85ec3abfa712e33464612e82f8..4971ef343a8108bf26621ace75607ffe0e0afb9b 100644 --- a/backend/db/models.py +++ b/backend/db/models.py @@ -14,4 +14,4 @@ class Records(Base): place = Column(String(10)) date = Column(DateTime) density = Column(Float) - waiting_time = Column(Interval) \ No newline at end of file + waiting_time = Column(Interval) diff --git a/backend/db/schemas.py b/backend/db/schemas.py index 600efc71449952c86b53af757d92db826c9642f4..5f10ba98ce31f03dee794dee223821eee2754bef 100644 --- a/backend/db/schemas.py +++ b/backend/db/schemas.py @@ -8,14 +8,17 @@ from pydantic import BaseModel, Field class RecordBase(BaseModel): """Records base schema""" - place: str = Field(..., title="Name of the RU corresponding the given record") + place: str = Field(..., + title="Name of the RU corresponding the given record") date: datetime = Field(..., title="Date of the record") density: float = Field(..., title="Estimated density of people") - waiting_time: Optional[timedelta] = Field(title="Estimated waiting time for people coming at this date") - + waiting_time: Optional[timedelta] = Field( + title="Estimated waiting time for people coming at this date") + + class Record(RecordBase): """Database records schema""" id: int class Config: - orm_mode = True \ No newline at end of file + orm_mode = True diff --git a/backend/main.py b/backend/main.py index 3d1329d138ee8e3142058bcde1a28087a3a3ea39..ac7fe9c002f68605e18a98f8c676d20fc788bbcf 100644 --- a/backend/main.py +++ b/backend/main.py @@ -25,6 +25,7 @@ app.add_middleware( allow_headers=["*"] ) + def get_db(): """Create a database session.""" db = database.SessionLocal() @@ -83,4 +84,4 @@ async def estimate_(id: str) -> float: pred_map = np.squeeze(model.predict(input_image)) count_prediction = np.sum(pred_map) return count_prediction -""" \ No newline at end of file +"""