Skip to content

Commit

Permalink
fix timestamp error in table view (#1960)
Browse files Browse the repository at this point in the history
  • Loading branch information
flametest authored and mistercrunch committed Jan 13, 2017
1 parent 1dbfb99 commit 87eacf8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 1 addition & 3 deletions superset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from datetime import datetime, timedelta
import json
import simplejson
import logging
import pickle
import re
Expand Down Expand Up @@ -1405,8 +1404,7 @@ def explore_json(self, datasource_type, datasource_id):
status = 500

return Response(
simplejson.dumps(
payload, default=utils.json_int_dttm_ser, ignore_nan=True),
viz_obj.json_dumps(payload),
status=status,
mimetype="application/json")

Expand Down
11 changes: 7 additions & 4 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,7 @@ def get_payload(self, force=False):
payload['cached_dttm'] = datetime.now().isoformat().split('.')[0]
logging.info("Caching for the next {} seconds".format(
cache_timeout))
data = json.dumps(
payload,
default=utils.json_int_dttm_ser, ignore_nan=True
)
data = self.json_dumps(payload)
if PY3:
data = bytes(data, 'utf-8')
try:
Expand All @@ -399,6 +396,9 @@ def get_payload(self, force=False):
payload['is_cached'] = is_cached
return payload

def json_dumps(self, obj):
return json.dumps(obj, default=utils.json_int_dttm_ser, ignore_nan=True)

@property
def data(self):
"""This is the data object serialized to the js layer"""
Expand Down Expand Up @@ -538,6 +538,9 @@ def get_data(self):
columns=list(df.columns),
)

def json_dumps(self, obj):
return json.dumps(obj, default=utils.json_iso_dttm_ser)


class PivotTableViz(BaseViz):

Expand Down

0 comments on commit 87eacf8

Please sign in to comment.