mirror of
https://github.com/apache/superset.git
synced 2026-05-30 04:39:20 +00:00
chore: Remove legacy SIP-15 interim logic/flags (#18936)
* chore: Remove legacy SIP-15 logic * Update ab9a9d86e695_deprecate_time_range_endpoints.py * Update UPDATING.md * Update UPDATING.md * Update UPDATING.md Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
@@ -30,7 +30,6 @@ const createProps = () => ({
|
||||
datasource: '34__table',
|
||||
slice_id: 456,
|
||||
url_params: {},
|
||||
time_range_endpoints: ['unknown', 'inclusive'],
|
||||
time_range: 'Last week',
|
||||
all_columns_x: 'source',
|
||||
all_columns_y: 'target',
|
||||
|
||||
@@ -31,7 +31,6 @@ const createProps = () => ({
|
||||
datasource: '49__table',
|
||||
slice_id: 318,
|
||||
url_params: {},
|
||||
time_range_endpoints: ['inclusive', 'exclusive'],
|
||||
granularity_sqla: 'time_start',
|
||||
time_range: 'No filter',
|
||||
all_columns_x: ['age'],
|
||||
@@ -65,7 +64,6 @@ const createProps = () => ({
|
||||
row_limit: 10000,
|
||||
slice_id: 318,
|
||||
time_range: 'No filter',
|
||||
time_range_endpoints: ['inclusive', 'exclusive'],
|
||||
url_params: {},
|
||||
viz_type: 'histogram',
|
||||
x_axis_label: 'age',
|
||||
|
||||
@@ -30,7 +30,6 @@ const createProps = () => ({
|
||||
datasource: '49__table',
|
||||
slice_id: 318,
|
||||
url_params: {},
|
||||
time_range_endpoints: ['inclusive', 'exclusive'],
|
||||
granularity_sqla: 'time_start',
|
||||
time_range: 'No filter',
|
||||
all_columns_x: ['age'],
|
||||
@@ -66,7 +65,6 @@ const createProps = () => ({
|
||||
row_limit: 10000,
|
||||
slice_id: 318,
|
||||
time_range: 'No filter',
|
||||
time_range_endpoints: ['inclusive', 'exclusive'],
|
||||
url_params: {},
|
||||
viz_type: 'histogram',
|
||||
x_axis_label: 'age',
|
||||
|
||||
@@ -48,7 +48,6 @@ const createProps = () => ({
|
||||
row_limit: 10000,
|
||||
slice_id: 318,
|
||||
time_range: 'No filter',
|
||||
time_range_endpoints: ['inclusive', 'exclusive'],
|
||||
url_params: {},
|
||||
viz_type: 'histogram',
|
||||
x_axis_label: 'age',
|
||||
@@ -108,7 +107,7 @@ fetchMock.get('glob:*/api/v1/chart/318', {
|
||||
},
|
||||
],
|
||||
params:
|
||||
'{"adhoc_filters": [], "all_columns_x": ["age"], "color_scheme": "supersetColors", "datasource": "42__table", "granularity_sqla": "time_start", "groupby": null, "label_colors": {}, "link_length": "25", "queryFields": {"groupby": "groupby"}, "row_limit": 10000, "slice_id": 1380, "time_range": "No filter", "time_range_endpoints": ["inclusive", "exclusive"], "url_params": {}, "viz_type": "histogram", "x_axis_label": "age", "y_axis_label": "count"}',
|
||||
'{"adhoc_filters": [], "all_columns_x": ["age"], "color_scheme": "supersetColors", "datasource": "42__table", "granularity_sqla": "time_start", "groupby": null, "label_colors": {}, "link_length": "25", "queryFields": {"groupby": "groupby"}, "row_limit": 10000, "slice_id": 1380, "time_range": "No filter", "url_params": {}, "viz_type": "histogram", "x_axis_label": "age", "y_axis_label": "count"}',
|
||||
slice_name: 'Age distribution of respondents',
|
||||
viz_type: 'histogram',
|
||||
},
|
||||
|
||||
@@ -18,13 +18,7 @@
|
||||
*/
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import rison from 'rison';
|
||||
import {
|
||||
SupersetClient,
|
||||
styled,
|
||||
t,
|
||||
TimeRangeEndpoints,
|
||||
useTheme,
|
||||
} from '@superset-ui/core';
|
||||
import { SupersetClient, styled, t, useTheme } from '@superset-ui/core';
|
||||
import {
|
||||
buildTimeRangeString,
|
||||
formatTimeRange,
|
||||
@@ -71,10 +65,7 @@ const guessFrame = (timeRange: string): FrameType => {
|
||||
return 'Advanced';
|
||||
};
|
||||
|
||||
const fetchTimeRange = async (
|
||||
timeRange: string,
|
||||
endpoints?: TimeRangeEndpoints,
|
||||
) => {
|
||||
const fetchTimeRange = async (timeRange: string) => {
|
||||
const query = rison.encode_uri(timeRange);
|
||||
const endpoint = `/api/v1/time_range/?q=${query}`;
|
||||
try {
|
||||
@@ -84,7 +75,7 @@ const fetchTimeRange = async (
|
||||
response?.json?.result?.until || '',
|
||||
);
|
||||
return {
|
||||
value: formatTimeRange(timeRangeString, endpoints),
|
||||
value: formatTimeRange(timeRangeString),
|
||||
};
|
||||
} catch (response) {
|
||||
const clientError = await getClientErrorObject(response);
|
||||
@@ -171,7 +162,6 @@ interface DateFilterControlProps {
|
||||
name: string;
|
||||
onChange: (timeRange: string) => void;
|
||||
value?: string;
|
||||
endpoints?: TimeRangeEndpoints;
|
||||
type?: Type;
|
||||
}
|
||||
|
||||
@@ -181,7 +171,7 @@ export const getDateFilterControlTestId = testWithId(
|
||||
);
|
||||
|
||||
export default function DateFilterLabel(props: DateFilterControlProps) {
|
||||
const { value = DEFAULT_TIME_RANGE, endpoints, onChange, type } = props;
|
||||
const { value = DEFAULT_TIME_RANGE, onChange, type } = props;
|
||||
const [actualTimeRange, setActualTimeRange] = useState<string>(value);
|
||||
|
||||
const [show, setShow] = useState<boolean>(false);
|
||||
@@ -194,7 +184,7 @@ export default function DateFilterLabel(props: DateFilterControlProps) {
|
||||
const [tooltipTitle, setTooltipTitle] = useState<string>(value);
|
||||
|
||||
useEffect(() => {
|
||||
fetchTimeRange(value, endpoints).then(({ value: actualRange, error }) => {
|
||||
fetchTimeRange(value).then(({ value: actualRange, error }) => {
|
||||
if (error) {
|
||||
setEvalResponse(error || '');
|
||||
setValidTimeRange(false);
|
||||
@@ -235,18 +225,16 @@ export default function DateFilterLabel(props: DateFilterControlProps) {
|
||||
useDebouncedEffect(
|
||||
() => {
|
||||
if (lastFetchedTimeRange !== timeRangeValue) {
|
||||
fetchTimeRange(timeRangeValue, endpoints).then(
|
||||
({ value: actualRange, error }) => {
|
||||
if (error) {
|
||||
setEvalResponse(error || '');
|
||||
setValidTimeRange(false);
|
||||
} else {
|
||||
setEvalResponse(actualRange || '');
|
||||
setValidTimeRange(true);
|
||||
}
|
||||
setLastFetchedTimeRange(timeRangeValue);
|
||||
},
|
||||
);
|
||||
fetchTimeRange(timeRangeValue).then(({ value: actualRange, error }) => {
|
||||
if (error) {
|
||||
setEvalResponse(error || '');
|
||||
setValidTimeRange(false);
|
||||
} else {
|
||||
setEvalResponse(actualRange || '');
|
||||
setValidTimeRange(true);
|
||||
}
|
||||
setLastFetchedTimeRange(timeRangeValue);
|
||||
});
|
||||
}
|
||||
},
|
||||
SLOW_DEBOUNCE,
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { TimeRangeEndpoints } from '@superset-ui/core';
|
||||
|
||||
export const SEPARATOR = ' : ';
|
||||
|
||||
export const buildTimeRangeString = (since: string, until: string): string =>
|
||||
@@ -26,17 +24,11 @@ export const buildTimeRangeString = (since: string, until: string): string =>
|
||||
const formatDateEndpoint = (dttm: string, isStart?: boolean): string =>
|
||||
dttm.replace('T00:00:00', '') || (isStart ? '-∞' : '∞');
|
||||
|
||||
export const formatTimeRange = (
|
||||
timeRange: string,
|
||||
endpoints?: TimeRangeEndpoints,
|
||||
) => {
|
||||
export const formatTimeRange = (timeRange: string) => {
|
||||
const splitDateRange = timeRange.split(SEPARATOR);
|
||||
if (splitDateRange.length === 1) return timeRange;
|
||||
const formattedEndpoints = (endpoints || ['unknown', 'unknown']).map(
|
||||
(endpoint: string) => (endpoint === 'inclusive' ? '≤' : '<'),
|
||||
);
|
||||
|
||||
return `${formatDateEndpoint(splitDateRange[0], true)} ${
|
||||
formattedEndpoints[0]
|
||||
} col ${formattedEndpoints[1]} ${formatDateEndpoint(splitDateRange[1])}`;
|
||||
return `${formatDateEndpoint(
|
||||
splitDateRange[0],
|
||||
true,
|
||||
)} ≤ col < ${formatDateEndpoint(splitDateRange[1])}`;
|
||||
};
|
||||
|
||||
@@ -316,19 +316,16 @@ describe('formatTimeRange', () => {
|
||||
expect(formatTimeRange('Last 7 days')).toBe('Last 7 days');
|
||||
expect(formatTimeRange('No filter')).toBe('No filter');
|
||||
expect(formatTimeRange('Yesterday : Tomorrow')).toBe(
|
||||
'Yesterday < col < Tomorrow',
|
||||
'Yesterday ≤ col < Tomorrow',
|
||||
);
|
||||
expect(formatTimeRange('2010-07-30T00:00:00 : 2020-07-30T00:00:00')).toBe(
|
||||
'2010-07-30 ≤ col < 2020-07-30',
|
||||
);
|
||||
expect(formatTimeRange('2010-07-30T01:00:00 : ')).toBe(
|
||||
'2010-07-30T01:00:00 ≤ col < ∞',
|
||||
);
|
||||
expect(
|
||||
formatTimeRange('2010-07-30T00:00:00 : 2020-07-30T00:00:00', [
|
||||
'inclusive',
|
||||
'exclusive',
|
||||
]),
|
||||
).toBe('2010-07-30 ≤ col < 2020-07-30');
|
||||
expect(
|
||||
formatTimeRange('2010-07-30T01:00:00 : ', ['exclusive', 'inclusive']),
|
||||
).toBe('2010-07-30T01:00:00 < col ≤ ∞');
|
||||
expect(formatTimeRange(' : 2020-07-30T00:00:00')).toBe(
|
||||
'-∞ < col < 2020-07-30',
|
||||
'-∞ ≤ col < 2020-07-30',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user