fix(CrossFilters): Do not reload unrelated filters in global scope (#30252)
Co-authored-by: JUST.in DO IT <justin.park@airbnb.com>
This commit is contained in:
parent
c5594f2979
commit
dbab2fb955
|
|
@ -294,14 +294,14 @@ test('Recalculate charts in global filter scope when charts change', () => {
|
|||
id: 2,
|
||||
crossFilters: {
|
||||
scope: 'global',
|
||||
chartsInScope: [1, 3],
|
||||
chartsInScope: [1],
|
||||
},
|
||||
},
|
||||
'3': {
|
||||
id: 3,
|
||||
crossFilters: {
|
||||
scope: 'global',
|
||||
chartsInScope: [1, 2],
|
||||
chartsInScope: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -52,6 +52,20 @@ export const getCrossFiltersConfiguration = (
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const chartsByDataSource: Record<string, Set<number>> = Object.values(
|
||||
charts,
|
||||
).reduce((acc: Record<string, Set<number>>, chart) => {
|
||||
if (!chart.form_data) {
|
||||
return acc;
|
||||
}
|
||||
const { datasource } = chart.form_data;
|
||||
if (!acc[datasource]) {
|
||||
acc[datasource] = new Set();
|
||||
}
|
||||
acc[datasource].add(chart.id);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const globalChartConfiguration = metadata.global_chart_configuration?.scope
|
||||
? {
|
||||
scope: metadata.global_chart_configuration.scope,
|
||||
|
|
@ -97,10 +111,13 @@ export const getCrossFiltersConfiguration = (
|
|||
},
|
||||
};
|
||||
}
|
||||
const chartDataSource = charts[chartId].form_data.datasource;
|
||||
chartConfiguration[chartId].crossFilters.chartsInScope =
|
||||
isCrossFilterScopeGlobal(chartConfiguration[chartId].crossFilters.scope)
|
||||
? globalChartConfiguration.chartsInScope.filter(
|
||||
id => id !== Number(chartId),
|
||||
id =>
|
||||
id !== Number(chartId) &&
|
||||
chartsByDataSource[chartDataSource]?.has(id),
|
||||
)
|
||||
: getChartIdsInFilterScope(
|
||||
chartConfiguration[chartId].crossFilters.scope,
|
||||
|
|
|
|||
Loading…
Reference in New Issue