fix(chalice): use card's global filters instead of series' filters (#2857)
(cherry picked from commit 94b541c758)
This commit is contained in:
parent
d6e0865b8a
commit
c151d55c67
1 changed files with 41 additions and 23 deletions
|
|
@ -972,33 +972,51 @@ class CardSessionsSchema(_TimedSchema, _PaginatedSchema):
|
|||
|
||||
return self
|
||||
|
||||
# We don't need this as the UI is expecting filters to override the full series' filters
|
||||
# @model_validator(mode="after")
|
||||
# def __merge_out_filters_with_series(self):
|
||||
# for f in self.filters:
|
||||
# for s in self.series:
|
||||
# found = False
|
||||
#
|
||||
# if f.is_event:
|
||||
# sub = s.filter.events
|
||||
# else:
|
||||
# sub = s.filter.filters
|
||||
#
|
||||
# for e in sub:
|
||||
# if f.type == e.type and f.operator == e.operator:
|
||||
# found = True
|
||||
# if f.is_event:
|
||||
# # If extra event: append value
|
||||
# for v in f.value:
|
||||
# if v not in e.value:
|
||||
# e.value.append(v)
|
||||
# else:
|
||||
# # If extra filter: override value
|
||||
# e.value = f.value
|
||||
# if not found:
|
||||
# sub.append(f)
|
||||
#
|
||||
# self.filters = []
|
||||
#
|
||||
# return self
|
||||
|
||||
# UI is expecting filters to override the full series' filters
|
||||
@model_validator(mode="after")
|
||||
def __merge_out_filters_with_series(self):
|
||||
def __override_series_filters_with_outer_filters(self):
|
||||
if len(self.filters) > 0:
|
||||
events = []
|
||||
filters = []
|
||||
for f in self.filters:
|
||||
if f.is_event:
|
||||
events.append(f)
|
||||
else:
|
||||
filters.append(f)
|
||||
for s in self.series:
|
||||
found = False
|
||||
|
||||
if f.is_event:
|
||||
sub = s.filter.events
|
||||
else:
|
||||
sub = s.filter.filters
|
||||
|
||||
for e in sub:
|
||||
if f.type == e.type and f.operator == e.operator:
|
||||
found = True
|
||||
if f.is_event:
|
||||
# If extra event: append value
|
||||
for v in f.value:
|
||||
if v not in e.value:
|
||||
e.value.append(v)
|
||||
else:
|
||||
# If extra filter: override value
|
||||
e.value = f.value
|
||||
if not found:
|
||||
sub.append(f)
|
||||
|
||||
s.filter.events = events
|
||||
s.filter.filters = filters
|
||||
self.filters = []
|
||||
|
||||
return self
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue