From a005e4568f14f32be23c317dc484b904ddc71dd9 Mon Sep 17 00:00:00 2001 From: Grace Guo Date: Tue, 11 Feb 2020 13:11:17 -0800 Subject: [PATCH] [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 --- superset-frontend/src/chart/chartAction.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/superset-frontend/src/chart/chartAction.js b/superset-frontend/src/chart/chartAction.js index 3563725232c95..657d0be8c167e 100644 --- a/superset-frontend/src/chart/chartAction.js +++ b/superset-frontend/src/chart/chartAction.js @@ -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));