Skip to content

Commit

Permalink
More bug squashing
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 19, 2015
1 parent 6f1fa51 commit 4edbbd3
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ class BaseViz(object):
def __init__(self, datasource, form_data):
self.datasource = datasource
if isinstance(form_data, MultiDict):
self.args = form_data.to_dict(flat=True)
self.args = form_data.to_dict(flat=False)
else:
self.args = form_data
self.form_data = form_data
self.token = self.args.get('token', 'token_' + uuid.uuid4().hex[:8])

as_list = ('metrics', 'groupby')
d = self.args
for m in as_list:
if m in d and d[m] and not isinstance(d[m], list):
d[m] = [d[m]]
for k, v in self.args.items():
if k in as_list and not isinstance(v, list):
self.args[k] = [v]
elif k not in as_list and isinstance(v, list) and v:
self.args[k] = v[0]

self.metrics = self.args.get('metrics') or ['count']
self.groupby = self.args.get('groupby') or []

Expand All @@ -57,18 +59,14 @@ def get_df(self):
self.error_msg = ""
self.results = None

#try:
self.results = self.bake_query()
df = self.results.df
if df is not None:
if df is None or df.empty:
raise Exception("No data, review your incantations!")
else:
if 'timestamp' in df.columns:
df.timestamp = pd.to_datetime(df.timestamp)
return df
'''
except Exception as e:
logging.exception(e)
self.error_msg = str(e)
'''

@property
def form(self):
Expand Down

0 comments on commit 4edbbd3

Please sign in to comment.