From 8682196eb88e3046f9c4e6b6fc471804531c928c Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 22 Dec 2015 15:52:15 -0800 Subject: [PATCH] Getting filters to a reasonable place --- panoramix/forms.py | 1 + panoramix/models.py | 1 - panoramix/static/panoramix.js | 6 +----- panoramix/viz.py | 8 ++++++++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/panoramix/forms.py b/panoramix/forms.py index 0dc42606d3d00..13c3bb559d188 100644 --- a/panoramix/forms.py +++ b/panoramix/forms.py @@ -403,6 +403,7 @@ class QueryForm(OmgWtForm): css_classes = field_css_classes standalone = HiddenField() async = HiddenField() + extra_filters = HiddenField() json = HiddenField() slice_id = HiddenField() slice_name = HiddenField() diff --git a/panoramix/models.py b/panoramix/models.py index b28189913dfab..bbbb44ce3ca15 100644 --- a/panoramix/models.py +++ b/panoramix/models.py @@ -508,7 +508,6 @@ def query( con=engine ) sql = sqlparse.format(sql, reindent=True) - print(sql) return QueryResult( df=df, duration=datetime.now() - qry_start_dttm, query=sql) diff --git a/panoramix/static/panoramix.js b/panoramix/static/panoramix.js index a556d1e5aaa1d..7ba190427f30a 100644 --- a/panoramix/static/panoramix.js +++ b/panoramix/static/panoramix.js @@ -30,11 +30,7 @@ var px = (function() { if (dashboard !== undefined){ for (var f in dashboard.filters) { if (slice_id !== f){ - form_data[dashboard.filters[f][0]] = dashboard.filters[f][1]; - form_data['flt_col_1'] = dashboard.filters[f][0]; - form_data['flt_op_1'] = 'in'; - form_data['flt_eq_1'] = dashboard.filters[f][1][0]; - //form_data['extra_filters'] = JSON.stringify(dashboard.filters) + form_data['extra_filters'] = JSON.stringify(dashboard.filters) } } } diff --git a/panoramix/viz.py b/panoramix/viz.py index 5d2266b162e8b..27f5b5c1901a8 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -156,6 +156,14 @@ def query_filters(self): eq = form_data.get("flt_eq_" + str(i)) if col and op and eq: filters.append((col, op, eq)) + + # Extra filters (coming from dashboard) + extra_filters = form_data.get('extra_filters', []) + if extra_filters: + extra_filters = json.loads(extra_filters) + for slice_id, (col, vals) in extra_filters.items(): + filters += [(col, 'in', ",".join(vals))] + return filters def query_obj(self):