fix: filtering for any method based on user prio

This commit is contained in:
2024-02-19 16:28:38 +01:00
parent 2a277230b2
commit 38e60c6898

View File

@@ -162,10 +162,16 @@ def get_dispatch():
lines_timeout = lines_unfiltered.filter(DispatchObject.timestamp < timeout_cutoff_timestamp) lines_timeout = lines_unfiltered.filter(DispatchObject.timestamp < timeout_cutoff_timestamp)
if method != "all": if method != "all":
dispatch_objects = lines_timeout.filter(DispatchObject.method==method).all() dispatch_objects = lines_timeout.filter(DispatchObject.method==method).all()
user_settings = db.session.query(UserSettings).filter(UserSettings.username==user)
# get matchin "any" methods #
if method == user_settings.get_highest_prio_method(): if method == user_settings.get_highest_prio_method():
dispatch_objects += lines_timeout.filter(DispatchObject.method=="any").all() dispatch_objects_any = lines_timeout.filter(DispatchObject.method=="any").all()
for d in dispatch_objects_any:
user_settings = db.session.query(UserSettings).filter(UserSettings.username==d.username).first()
if user_settings and user_settings.get_highest_prio_method() == method:
dispatch_objects += d
else: else:
dispatch_objects = lines_timeout.all() dispatch_objects = lines_timeout.all()