fixed code style

This commit is contained in:
Junxian Wu
2016-05-23 17:56:01 -07:00
parent 34b6278297
commit eba364d64a
3 changed files with 6 additions and 4 deletions

View File

@@ -428,10 +428,10 @@ class Database(Model, AuditMixinNullable):
if self.sqlalchemy_uri.startswith(db_type):
return grains
def dttm_converter(self, dttm, tf = None):
def dttm_converter(self, dttm, tf=None):
"""Returns a string that the database flavor understands as a date"""
if tf is None or tf == '':
tf = '%Y-%m-%d %H:%M:%S.%f'
"""Returns a string that the database flavor understands as a date"""
default = "'{}'".format(dttm.strftime(tf))
iso = dttm.isoformat()
d = {

View File

@@ -290,7 +290,8 @@ class TableModelView(CaravelModelView, DeleteMixin): # noqa
'table_name', 'database', 'schema', 'timestamp_format',
'default_endpoint', 'offset', 'cache_timeout']
edit_columns = [
'table_name', 'is_featured', 'database', 'schema', 'timestamp_format', 'description', 'owner',
'table_name', 'is_featured', 'database', 'schema',
'timestamp_format', 'description', 'owner',
'main_dttm_col', 'default_endpoint', 'offset', 'cache_timeout']
related_views = [TableColumnInlineView, SqlMetricInlineView]
base_order = ('changed_on', 'desc')

View File

@@ -151,7 +151,8 @@ class BaseViz(object):
raise Exception("No data, review your incantations!")
else:
if 'timestamp' in df.columns:
df.timestamp = pd.to_datetime(df.timestamp, utc=False, format=timestamp_format)
df.timestamp = pd.to_datetime(df.timestamp,
utc=False, format=timestamp_format)
if self.datasource.offset:
df.timestamp += timedelta(hours=self.datasource.offset)
df = df.fillna(0)