2121 init_db ,
2222 WirelessBase ,
2323 APClientBase ,
24- get_apclient_db_dep
24+ get_apclient_db_dep ,
25+ get_wireless_db_dep
2526)
2627from ap_monitor .app .models import (
2728 Campus , Building , ClientCount ,
@@ -714,13 +715,12 @@ def insert_apclientcount_data(device_info_list, timestamp, session=None):
714715 raise
715716
716717@app .get ("/aps" , response_model = List [dict ], tags = ["Access Points" ])
717- def get_aps (db : Session = Depends (get_wireless_db )):
718+ def get_aps (db : Session = Depends (get_wireless_db_dep )):
718719 """Get all access points from the database."""
719720 try :
720721 logger .info ("Fetching AP data from the database" )
721722 aps = db .query (AccessPoint ).all ()
722723 logger .info (f"Retrieved { len (aps )} AP records" )
723-
724724 return [{
725725 "apid" : ap .apid ,
726726 "apname" : ap .apname ,
@@ -774,7 +774,7 @@ def get_client_counts(
774774 raise HTTPException (status_code = 500 , detail = str (e ))
775775
776776@app .get ("/buildings" , response_model = List [dict ], tags = ["Buildings" ])
777- def get_buildings (db : Session = Depends (get_wireless_db )):
777+ def get_buildings (db : Session = Depends (get_wireless_db_dep )):
778778 """Get list of buildings with their details."""
779779 try :
780780 logger .info ("Fetching list of buildings" )
@@ -792,7 +792,7 @@ def get_buildings(db: Session = Depends(get_wireless_db)):
792792 raise HTTPException (status_code = 500 , detail = "Internal server error" )
793793
794794@app .get ("/floors/{building_id}" , response_model = List [dict ], tags = ["Floors" ])
795- def get_floors (building_id : int , db : Session = Depends (get_wireless_db )):
795+ def get_floors (building_id : int , db : Session = Depends (get_wireless_db_dep )):
796796 """Get floors for a specific building."""
797797 try :
798798 floors = db .query (Floor ).filter_by (buildingid = building_id ).all ()
@@ -810,7 +810,7 @@ def get_floors(building_id: int, db: Session = Depends(get_wireless_db)):
810810 raise HTTPException (status_code = 500 , detail = "Internal server error" )
811811
812812@app .get ("/rooms/{floor_id}" , response_model = List [dict ], tags = ["Rooms" ])
813- def get_rooms (floor_id : int , db : Session = Depends (get_wireless_db )):
813+ def get_rooms (floor_id : int , db : Session = Depends (get_wireless_db_dep )):
814814 """Get rooms for a specific floor."""
815815 try :
816816 rooms = db .query (Room ).filter_by (floorid = floor_id ).all ()
@@ -827,7 +827,7 @@ def get_rooms(floor_id: int, db: Session = Depends(get_wireless_db)):
827827 raise HTTPException (status_code = 500 , detail = "Internal server error" )
828828
829829@app .get ("/radio-types" , response_model = List [dict ], tags = ["Radio Types" ])
830- def get_radio_types (db : Session = Depends (get_wireless_db )):
830+ def get_radio_types (db : Session = Depends (get_wireless_db_dep )):
831831 """Get all radio types."""
832832 try :
833833 radio_types = db .query (RadioType ).all ()
@@ -843,7 +843,7 @@ def get_radio_types(db: Session = Depends(get_wireless_db)):
843843 raise HTTPException (status_code = 500 , detail = "Internal server error" )
844844
845845@app .post ("/wireless/campuses/" , response_model = CampusResponse )
846- def create_campus (campus : CampusCreate , db : Session = Depends (get_wireless_db )):
846+ def create_campus (campus : CampusCreate , db : Session = Depends (get_wireless_db_dep )):
847847 """Create a new campus."""
848848 db_campus = Campus (campus_name = campus .campus_name )
849849 db .add (db_campus )
@@ -852,12 +852,12 @@ def create_campus(campus: CampusCreate, db: Session = Depends(get_wireless_db)):
852852 return db_campus
853853
854854@app .get ("/wireless/campuses/" , response_model = List [CampusResponse ])
855- def get_campuses (db : Session = Depends (get_wireless_db )):
855+ def get_campuses (db : Session = Depends (get_wireless_db_dep )):
856856 """Get all campuses."""
857857 return db .query (Campus ).all ()
858858
859859@app .post ("/wireless/buildings/" , response_model = BuildingResponse )
860- def create_building (building : BuildingCreate , db : Session = Depends (get_wireless_db )):
860+ def create_building (building : BuildingCreate , db : Session = Depends (get_wireless_db_dep )):
861861 """Create a new building."""
862862 db_building = Building (** building .dict ())
863863 db .add (db_building )
@@ -866,15 +866,15 @@ def create_building(building: BuildingCreate, db: Session = Depends(get_wireless
866866 return db_building
867867
868868@app .get ("/wireless/buildings/" , response_model = List [BuildingResponse ])
869- def get_wireless_buildings (campus_id : Optional [int ] = None , db : Session = Depends (get_wireless_db )):
869+ def get_wireless_buildings (campus_id : Optional [int ] = None , db : Session = Depends (get_wireless_db_dep )):
870870 """Get all buildings, optionally filtered by campus."""
871871 query = db .query (Building )
872872 if campus_id :
873873 query = query .filter (Building .campus_id == campus_id )
874874 return query .all ()
875875
876876@app .post ("/wireless/client-counts/" , response_model = ClientCountResponse )
877- def create_client_count (count : ClientCountCreate , db : Session = Depends (get_wireless_db )):
877+ def create_client_count (count : ClientCountCreate , db : Session = Depends (get_wireless_db_dep )):
878878 """Create a new client count."""
879879 db_count = ClientCount (** count .dict ())
880880 db .add (db_count )
@@ -887,7 +887,7 @@ def get_wireless_client_counts(
887887 building_id : Optional [int ] = None ,
888888 start_time : Optional [datetime ] = None ,
889889 end_time : Optional [datetime ] = None ,
890- db : Session = Depends (get_wireless_db )
890+ db : Session = Depends (get_wireless_db_dep )
891891):
892892 """Get client counts with optional filters."""
893893 query = db .query (ClientCount )
0 commit comments