sql_app: init_db: added connections and open/close commands
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
0a4a560ac5
commit
ae5f4e040d
@ -65,11 +65,6 @@ def init_allowance():
|
|||||||
crud.create_user_link_to_iot(db, 1, 1)
|
crud.create_user_link_to_iot(db, 1, 1)
|
||||||
|
|
||||||
def init_sensor_data():
|
def init_sensor_data():
|
||||||
# humidity : int
|
|
||||||
# people : int
|
|
||||||
# temperature : int
|
|
||||||
# smoke_sensor_reading : int
|
|
||||||
# token: str
|
|
||||||
|
|
||||||
for i in range(50):
|
for i in range(50):
|
||||||
room_data = \
|
room_data = \
|
||||||
@ -82,11 +77,52 @@ def init_sensor_data():
|
|||||||
token='dummy')
|
token='dummy')
|
||||||
crud.record_room_sensor_data(db, room_data)
|
crud.record_room_sensor_data(db, room_data)
|
||||||
|
|
||||||
|
def init_open_close_requests():
|
||||||
|
user = crud.get_user_by_email(db, "hisham@banafa.com.sa")
|
||||||
|
crud.set_open_door_request(db, 1, 10)
|
||||||
|
log_entry = schemas.DoorAccessLog(user_id=user.id,
|
||||||
|
iot_id=1,
|
||||||
|
command="OPEN",
|
||||||
|
timestamp=datetime.now())
|
||||||
|
crud.record_door_access_log(db, log_entry)
|
||||||
|
|
||||||
|
log_entry = schemas.DoorAccessLog(user_id=user.id,
|
||||||
|
iot_id=1,
|
||||||
|
command="OPEN",
|
||||||
|
timestamp=datetime.now())
|
||||||
|
crud.record_door_access_log(db, log_entry)
|
||||||
|
|
||||||
|
log_entry = schemas.DoorAccessLog(user_id=user.id,
|
||||||
|
iot_id=1,
|
||||||
|
command="OPEN",
|
||||||
|
timestamp=datetime.now())
|
||||||
|
crud.record_door_access_log(db, log_entry)
|
||||||
|
|
||||||
|
|
||||||
|
log_entry = schemas.DoorAccessLog(user_id=user.id,
|
||||||
|
iot_id=1,
|
||||||
|
command="CLOSE",
|
||||||
|
timestamp=datetime.now())
|
||||||
|
crud.record_door_access_log(db, log_entry)
|
||||||
|
|
||||||
|
def init_user_connections():
|
||||||
|
users = [ crud.get_user(db, 1),
|
||||||
|
crud.get_user(db, 2),
|
||||||
|
crud.get_user(db, 3)]
|
||||||
|
|
||||||
|
for i in range(3):
|
||||||
|
print(users[i])
|
||||||
|
crud.record_user_connection(db, users[i], datetime.now())
|
||||||
|
crud.record_user_connection(db, users[i], datetime.now())
|
||||||
|
crud.record_user_connection(db, users[i], datetime.now())
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
init_user()
|
init_user()
|
||||||
init_door()
|
init_door()
|
||||||
init_monitor()
|
init_monitor()
|
||||||
init_allowance()
|
init_allowance()
|
||||||
init_sensor_data()
|
init_sensor_data()
|
||||||
|
init_open_close_requests()
|
||||||
|
init_user_connections()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user