Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
chore: translate fractional time grains
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bodley committed Oct 13, 2021
1 parent e5e8b66 commit 089a642
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TimeFormatsForGranularity: Record<TimeGranularity, string> = {
[TimeGranularity.FIVE_MINUTES]: MINUTE,
[TimeGranularity.TEN_MINUTES]: MINUTE,
[TimeGranularity.FIFTEEN_MINUTES]: MINUTE,
[TimeGranularity.HALF_HOUR]: MINUTE,
[TimeGranularity.THIRTY_MINUTES]: MINUTE,
[TimeGranularity.HOUR]: '%Y-%m-%d %H:00',
[TimeGranularity.DAY]: DATABASE_DATE,
[TimeGranularity.WEEK]: DATABASE_DATE,
Expand Down
4 changes: 2 additions & 2 deletions packages/superset-ui-core/src/time-format/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const TimeGranularity = {
FIVE_MINUTES: 'PT5M',
TEN_MINUTES: 'PT10M',
FIFTEEN_MINUTES: 'PT15M',
HALF_HOUR: 'PT0.5H',
THIRTY_MINUTES: 'PT30M',
HOUR: 'PT1H',
DAY: 'P1D',
WEEK: 'P1W',
Expand All @@ -21,7 +21,7 @@ export const TimeGranularity = {
WEEK_ENDING_SATURDAY: 'P1W/1970-01-03T00:00:00Z',
WEEK_ENDING_SUNDAY: 'P1W/1970-01-04T00:00:00Z',
MONTH: 'P1M',
QUARTER: 'P0.25Y',
QUARTER: 'P3M',
YEAR: 'P1Y',
} as const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function computeEndTimeFromGranularity(
return new Date(time.getTime() + MS_IN_MINUTE * 10 - 1);
case TimeGranularity.FIFTEEN_MINUTES:
return new Date(time.getTime() + MS_IN_MINUTE * 15 - 1);
case TimeGranularity.HALF_HOUR:
case TimeGranularity.THIRTY_MINUTES:
return new Date(time.getTime() + MS_IN_MINUTE * 30 - 1);
case TimeGranularity.HOUR:
return new Date(time.getTime() + MS_IN_HOUR - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('TimeFormatterRegistrySingleton', () => {
expect(formatTime(undefined, date, TimeGranularity.FIFTEEN_MINUTES)).toEqual(
'2020-05-10 00:00 — 2020-05-10 00:14',
);
expect(formatTime(undefined, date, TimeGranularity.HALF_HOUR)).toEqual(
expect(formatTime(undefined, date, TimeGranularity.THIRTY_MINUTES)).toEqual(
'2020-05-10 00:00 — 2020-05-10 00:29',
);
expect(formatTime(undefined, date, TimeGranularity.HOUR)).toEqual('2020-05-10 00:00');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('createTimeRangeFromGranularity(time, granularity, useLocalTime)', () =
expect(testUTC(TimeGranularity.FIFTEEN_MINUTES, 2020, 4, 15)).toEqual(
'2020-05-15 00:00:00.000 — 2020-05-15 00:14:59.999',
);
expect(testUTC(TimeGranularity.HALF_HOUR, 2020, 4, 15)).toEqual(
expect(testUTC(TimeGranularity.THIRTY_MINUTES, 2020, 4, 15)).toEqual(
'2020-05-15 00:00:00.000 — 2020-05-15 00:29:59.999',
);
expect(testUTC(TimeGranularity.HOUR, 2020, 4, 15)).toEqual(
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('createTimeRangeFromGranularity(time, granularity, useLocalTime)', () =
expect(testLocal(TimeGranularity.FIFTEEN_MINUTES, 2020, 4, 15)).toEqual(
'2020-05-15 00:00:00.000 — 2020-05-15 00:14:59.999',
);
expect(testLocal(TimeGranularity.HALF_HOUR, 2020, 4, 15)).toEqual(
expect(testLocal(TimeGranularity.THIRTY_MINUTES, 2020, 4, 15)).toEqual(
'2020-05-15 00:00:00.000 — 2020-05-15 00:29:59.999',
);
expect(testLocal(TimeGranularity.HOUR, 2020, 4, 15)).toEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
["P1D", "day"],
["P1W", "week"],
["P1M", "month"],
["P0.25Y", "quarter"],
["P3M", "quarter"],
["P1Y", "year"]
],
"main_dttm_col": "ds",
Expand All @@ -216,7 +216,7 @@
"include_search": true,
"url_params": {},
"granularity_sqla": "ds",
"time_grain_sqla": "P0.25Y",
"time_grain_sqla": "P3M",
"time_range": "No filter",
"query_mode": "aggregate",
"groupby": ["state", "gender", "name"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const formData = {
a: 1,
},
compareLag: 1,
timeGrainSqla: 'P0.25Y' as TimeGranularity,
timeGrainSqla: 'P3M' as TimeGranularity,
compareSuffix: 'over last quarter',
vizType: 'big_number',
yAxisFormat: '.3s',
Expand All @@ -46,7 +46,7 @@ const rawFormData = {
a: 1,
},
compare_lag: 1,
time_grain_sqla: 'P0.25Y' as TimeGranularity,
time_grain_sqla: 'P3M' as TimeGranularity,
compare_suffix: 'over last quarter',
viz_type: 'big_number',
y_axis_format: '.3s',
Expand Down

0 comments on commit 089a642

Please sign in to comment.