You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jo...@apache.org on 2019/01/11 02:22:11 UTC
[incubator-superset] 07/43: added to_dict
This is an automated email from the ASF dual-hosted git repository.
johnbodley pushed a commit to branch feature--embeddable-charts-pilot
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 62ba4fc5dcd303da2310bfe5b3205fbb6624ecab
Author: Conglei Shi <co...@airbnb.com>
AuthorDate: Wed Nov 14 21:37:29 2018 -0800
added to_dict
---
superset/common/query_context.py | 2 +-
superset/common/query_object.py | 18 ++++++++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/superset/common/query_context.py b/superset/common/query_context.py
index 27e03a0..751da71 100644
--- a/superset/common/query_context.py
+++ b/superset/common/query_context.py
@@ -140,7 +140,7 @@ class QueryContext:
@property
def cache_timeout(self):
- if self.custom_cache_timeout not None:
+ if self.custom_cache_timeout is not None:
return self.custom_cache_timeout
if self.datasource.cache_timeout is not None:
return self.datasource.cache_timeout
diff --git a/superset/common/query_object.py b/superset/common/query_object.py
index d12620c..1a38885 100644
--- a/superset/common/query_object.py
+++ b/superset/common/query_object.py
@@ -44,13 +44,27 @@ class QueryObject:
self.extras = extras
def to_dict(self):
- raise NotImplementedError()
+ query_object_dict = {
+ 'granularity': self.granularity,
+ 'from_dttm': self.from_dttm,
+ 'to_dttm': self.to_dttm,
+ 'is_timeseries': self.is_timeseries,
+ 'groupby': self.groupby,
+ 'row_limit': self.row_limit,
+ 'filters': self.filter,
+ 'timeseries_limit': self.timeseries_limit,
+ 'timeseries_limit_metric': self.timeseries_limit_metric,
+ 'order_desc': self.order_desc,
+ 'prequeries': self.prequeries,
+ 'is_prequery': self.is_prequery,
+ }
+ query_object_dict.update(self.extras)
+ return query_object_dict
def cache_key(self, **extra):
"""
The cache key is made out of the key/values in `query_obj`, plus any
other key/values in `extra`
-
We remove datetime bounds that are hard values, and replace them with
the use-provided inputs to bounds, which may be time-relative (as in
"5 days ago" or "now").