Skip to content

Commit

Permalink
fixed wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Nik Sauer committed Nov 5, 2024
1 parent 99ce860 commit 07b1c41
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion code/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class StationStatus(Base):
__tablename__ = "StationStatus"

id = Column(Integer, primary_key=True, index=True)
Column(Integer, ForeignKey('stations.id'))
station_id = Column(Integer, ForeignKey('stations.id'))
timestamp = Column(DateTime)
level = Column(Integer)
message = Column(String)
36 changes: 23 additions & 13 deletions code/routers/station.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ async def wrapper(
station
*args,
db_station = db_station,
db = db,
**kwargs
)
return wrapper
Expand Down Expand Up @@ -194,29 +193,42 @@ async def get_current_station_data(

return Response(content=content, media_type=media_type)

'''

@router.post("/status", tags=["station"])
@validate_station_info
async def create_station_status(
station: StationDataCreate,
status: StationStatus,
db_station: Station
status_list: list[StationStatusCreate],

# von @validate_station_info
db_station: Station = Depends(lambda: None),
db: Session = Depends(get_db)
):

for status in status_list:
db_status = StationStatus(
station_id = db_station.id,
timestamp = status.time,
level = status.level,
message = status.message
)
db.add(db_status)
db.commit()
db.refresh(db_status)

return {"status": "success"}
'''


@router.post("/data", tags=["station"])
#@validate_station_info
@validate_station_info
async def create_station_data(
station: StationDataCreate,
sensors: SensorsCreate,
background_tasks: BackgroundTasks,
# Defaults are passed by @validate_station_info
db_station: Station = None,
db: Session = Depends(get_db),

# von @validate_station_info
db_station: Station = Depends(lambda: None),
db: Session = Depends(get_db)
):
# Empfangszeit des Requests erfassen
time_received = datetime.now()
Expand Down Expand Up @@ -264,8 +276,6 @@ async def create_station_data(

return {"status": "success"}

#import inspect
#print(inspect.signature(create_station_data))

@router.get("/historical", response_class=Response, tags=["station"])
async def get_historical_station_data(
Expand Down

0 comments on commit 07b1c41

Please sign in to comment.