Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[migration] Fix migration 3dda56f1c #5471

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the opposite, since it maps the old format to the new one:

'week_ending_saturday': 'P1W/1970-01-03T00:00:00Z',
'week_start_sunday': '1969-12-28T00:00:00Z/P1W',
'week_start_monday': '1969-12-29T00:00:00Z/P1W',
'week_starting_sunday': '1969-12-28T00:00:00Z/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