Skip to content

Commit

Permalink
[migration] Fix migration 3dda56f1c (apache#5471)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley authored and Grace Guo committed Jul 24, 2018
1 parent bea0a0a commit bfcc3a6
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from alembic import op
import isodate
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, Text
from sqlalchemy import Column, Integer, String, Text

from superset import db
from superset.utils import parse_human_timedelta
Expand All @@ -32,6 +32,7 @@ class Slice(Base):
__tablename__ = 'slices'

id = Column(Integer, primary_key=True)
datasource_type = Column(String(200))
params = Column(Text)


Expand All @@ -50,6 +51,12 @@ class Slice(Base):
'hour': 'PT1H',
'day': 'P1D',
'week': 'P1W',
'week_ending_saturday': 'P1W',
'week_start_sunday': 'P1W',
'week_start_monday': 'P1W',
'week_starting_sunday': 'P1W',
'P1W/1970-01-03T00:00:00Z': 'P1W',
'1969-12-28T00:00:00Z/P1W': 'P1W',
'month': 'P1M',
'quarter': 'P0.25Y',
'year': 'P1Y',
Expand Down Expand Up @@ -131,10 +138,11 @@ def upgrade():
continue

num_period_compare = int(params.get('num_period_compare'))
granularity = params.get('granularity') or params.get('time_grain_sqla')
period_ratio_type = params.get('period_ratio_type', 'growth')

granularity = (params.get('granularity') if chart.datasource_type == 'druid'
else params.get('time_grain_sqla'))
time_compare = compute_time_compare(granularity, num_period_compare)

period_ratio_type = params.get('period_ratio_type') or 'growth'
comparison_type = comparison_type_map[period_ratio_type.lower()]

params['time_compare'] = [time_compare]
Expand Down

0 comments on commit bfcc3a6

Please sign in to comment.