This commit is contained in:
@@ -23,7 +23,7 @@ class NewMedicineState(rx.State):
|
||||
updated_uuid: bool = False
|
||||
scanning: bool = False
|
||||
rate: float = 2
|
||||
lastupdatetime: int = time.time()
|
||||
lastupdatetime: int = 0
|
||||
|
||||
def start_scan(self):
|
||||
self.set_scanning(True)
|
||||
@@ -36,9 +36,11 @@ class NewMedicineState(rx.State):
|
||||
statement = select(Scan).order_by(Scan.timestamp.desc()).limit(1)
|
||||
results = session.exec(statement)
|
||||
self.last_scan = results.first()
|
||||
print(self.last_scan)
|
||||
if self.last_scan is None:
|
||||
return
|
||||
if self.last_scan.timestamp > self.lastupdatetime:
|
||||
print("Update last scan uuid")
|
||||
self.last_scan_uuid = self.last_scan.uuid
|
||||
if not self.show_med_add_form:
|
||||
self.update_medicine(self.last_scan.uuid)
|
||||
@@ -96,7 +98,7 @@ class NewMedicineState(rx.State):
|
||||
package_size=form_data["pkg_size"],
|
||||
pzn=form_data["pzn"] or "",
|
||||
owner_id=owner.id,
|
||||
uuid=State.last_scan_uuid,
|
||||
uuid=NewMedicineState.last_scan_uuid,
|
||||
cron=form_data["schedule"],
|
||||
)
|
||||
session.add(medicine)
|
||||
|
||||
Reference in New Issue
Block a user