mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
fix: update the time filter for 'Last Year' option in explore (#10829)
* Update explore time filter ranges * rm console statements * only update moment calculation for years * tests * add open/close test
This commit is contained in:
@@ -128,22 +128,23 @@ function getStateFromSeparator(value) {
|
||||
|
||||
function getStateFromCommonTimeFrame(value) {
|
||||
const units = `${value.split(' ')[1]}s`;
|
||||
let sinceMoment;
|
||||
|
||||
if (value === 'No filter') {
|
||||
sinceMoment = '';
|
||||
} else if (units === 'years') {
|
||||
sinceMoment = moment().utc().startOf(units).subtract(1, units);
|
||||
} else {
|
||||
sinceMoment = moment().utc().startOf('day').subtract(1, units);
|
||||
}
|
||||
|
||||
return {
|
||||
tab: TABS.DEFAULTS,
|
||||
type: TYPES.DEFAULTS,
|
||||
common: value,
|
||||
since:
|
||||
value === 'No filter'
|
||||
? ''
|
||||
: moment()
|
||||
.utc()
|
||||
.startOf('day')
|
||||
.subtract(1, units)
|
||||
.format(MOMENT_FORMAT),
|
||||
since: sinceMoment === '' ? '' : sinceMoment.format(MOMENT_FORMAT),
|
||||
until:
|
||||
value === 'No filter'
|
||||
? ''
|
||||
: moment().utc().startOf('day').format(MOMENT_FORMAT),
|
||||
sinceMoment === '' ? '' : sinceMoment.add(1, units).format(MOMENT_FORMAT),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -396,7 +397,6 @@ class DateFilterControl extends React.Component {
|
||||
));
|
||||
const timeFrames = COMMON_TIME_FRAMES.map(timeFrame => {
|
||||
const nextState = getStateFromCommonTimeFrame(timeFrame);
|
||||
|
||||
const timeRange = buildTimeRangeString(nextState.since, nextState.until);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user