diff --git a/sql_app/crud.py b/sql_app/crud.py index f8e3b24..8b5f22f 100644 --- a/sql_app/crud.py +++ b/sql_app/crud.py @@ -39,6 +39,9 @@ def get_access_log_for_door_by_door_mac(db: Session, bluetooth_mac : str): def get_access_log_for_user_by_id(db: Session, id : str): return db.query(models.DoorAccessLog).filter(models.DoorAccessLog.user_id == id).all() +def get_room_data_now(db: Session): + return db.query(models.RoomSensorData)[-1] + def create_user(db: Session, user: schemas.UserCreate): key = crypto.gen_new_key(user.password) salt = key[1] diff --git a/sql_app/main.py b/sql_app/main.py index 3934ec1..abc4042 100644 --- a/sql_app/main.py +++ b/sql_app/main.py @@ -189,6 +189,10 @@ def get_iot_access_list_for_user(db: Session = Depends(get_db), current_user: sc user = crud.get_user_by_username(db, current_user.username) return user.authorized_devices +@app.get("/admin/roominfo/now/", tags=['Admin']) +def get_room_data(db: Session = Depends(get_db)): + return crud.get_room_data_now(db) + @app.post("/users/open", tags=['Users']) def issue_open_door_command(command: schemas.OpenDoorRequestTime, db: Session = Depends(get_db),