[logging] Add data_age for cached chart (#9121)

* [logging] Add data_age for cached chart

* set data_age be null when is not cached data
This commit is contained in:
Grace Guo 2020-02-11 13:11:17 -08:00 committed by GitHub
parent 2913063924
commit a005e4568f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -18,6 +18,7 @@
*/
/* eslint no-undef: 'error' */
/* eslint no-param-reassign: ["error", { "props": false }] */
import moment from 'moment';
import { t } from '@superset-ui/translation';
import { SupersetClient } from '@superset-ui/connection';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
@ -254,6 +255,9 @@ export function exploreJSON(
has_extra_filters:
formData.extra_filters && formData.extra_filters.length > 0,
viz_type: formData.viz_type,
data_age: json.is_cached
? moment(new Date()).diff(moment.utc(json.cached_dttm))
: null,
}),
);
return dispatch(chartUpdateSucceeded(json, key));