schemas: fix loop handling for date dimension (#59691)
When date dimension is used with a loop, the filter is a list of date instead of date range dictionnary.
This commit is contained in:
parent
504c90cc7c
commit
d6fdb4affd
|
@ -288,8 +288,11 @@ class Dimension(Base):
|
|||
def build_filter(self, filter_values):
|
||||
value = self.filter_value or self.value
|
||||
|
||||
if self.type == 'date':
|
||||
assert isinstance(filter_values, dict) and set(filter_values.keys()) == {'start', 'end'}
|
||||
if (
|
||||
self.type == 'date'
|
||||
and isinstance(filter_values, dict)
|
||||
and set(filter_values.keys()) == {'start', 'end'}
|
||||
):
|
||||
filters = []
|
||||
values = []
|
||||
|
||||
|
@ -326,6 +329,8 @@ class Dimension(Base):
|
|||
filter_value = int(filter_value)
|
||||
elif self.type == 'bool':
|
||||
filter_value = bool(filter_value)
|
||||
elif self.type == 'date':
|
||||
filter_value = filter_value.isoformat()
|
||||
else:
|
||||
raise NotImplementedError
|
||||
except (ValueError, TypeError):
|
||||
|
|
|
@ -498,3 +498,18 @@ def test_date_dimension(schema1, app, admin):
|
|||
['09/01/2017', '1'],
|
||||
['10/01/2017', '1'],
|
||||
]
|
||||
|
||||
|
||||
def test_date_dimension_loop(schema1, app, admin):
|
||||
login(app, admin)
|
||||
response = app.get('/')
|
||||
response = response.click('schema1')
|
||||
response = response.click('Facts 1')
|
||||
form = response.form
|
||||
form.set('representation', 'table')
|
||||
form.set('measure', 'simple_count')
|
||||
form.set('loop', 'date')
|
||||
form.set('filter__date_0', '2017-01-01')
|
||||
form.set('filter__date_1', '2017-02-01')
|
||||
response = form.submit('visualize')
|
||||
assert get_table(response) == [['number of rows', '1']] * 10
|
||||
|
|
Loading…
Reference in New Issue