Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI-8857 - Fix unexpected filter MDX update during 4.3 to 5.0 migration #118

Merged
merged 6 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions src/4.3_to_5.0/__snapshots__/migrate_43_to_50.test.ts.snap

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/4.3_to_5.0/_migrateQuery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("_migrateQuery", () => {
"cubeName": "EquityDerivativesCube",
"elementType": "From",
},
"slicerAxis": undefined,
"slicerAxis": null,
"withClause": [],
},
"updateMode": "once",
Expand Down Expand Up @@ -56,7 +56,10 @@ describe("_migrateQuery", () => {
mdx: "SELECT FROM [EquityDerivativesCube] WHERE [Currency].[Currency].[AllMember].[EUR]",
};
const [{ query, filters }] = _migrateQuery({ legacyQuery, cube })!;
expect(stringify(query.mdx!)).toBe("SELECT FROM [EquityDerivativesCube]");

// Filters are unchanged in the query.
expect(stringify(query.mdx!)).toBe(legacyQuery.mdx);

expect(filters.length).toBe(1);
expect(stringify(filters[0])).toBe(
"[Currency].[Currency].[AllMember].[EUR]",
Expand Down
5 changes: 2 additions & 3 deletions src/4.3_to_5.0/_migrateQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
MdxDrillthrough,
MdxSelect,
} from "@activeviam/activeui-sdk-5.0";
import { getFilters, parse, setFilters } from "@activeviam/activeui-sdk-5.0";
import { getFilters, parse } from "@activeviam/activeui-sdk-5.0";
import { _fixErroneousExpansionMdx } from "./_fixErroneousExpansionMdx";
import {
LegacyContextValues,
Expand Down Expand Up @@ -91,13 +91,12 @@ export const _migrateQuery = <T extends MdxSelect | MdxDrillthrough>({
const filters = getFilters(improvedMdx, { cube }).map(
({ mdx: filterMdx }) => filterMdx,
);
const mdxWithoutFilters = setFilters(improvedMdx, { filters: [], cube });

// TODO UI-5036 Migrate query ranges.
return [
{
// Migrating the query preserves its type.
query: { mdx: mdxWithoutFilters as T, updateMode: migratedUpdateMode },
query: { mdx: improvedMdx as T, updateMode: migratedUpdateMode },
filters,
queryContext,
},
Expand Down
8 changes: 8 additions & 0 deletions src/4.3_to_5.0/migrateChart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe("migrateChart", () => {
it("returns the ActiveUI5 chart widget state corresponding to the given ActiveUI4 chart widget state", () => {
expect(migrateChart(legacyChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -83,6 +84,7 @@ describe("migrateChart", () => {
it("migrates a legacy line chart to a Plotly line chart", () => {
expect(migrateChart(legacyLineChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -113,6 +115,7 @@ describe("migrateChart", () => {
it("migrates a legacy area chart to a Plotly area chart", () => {
expect(migrateChart(legacyAreaChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -143,6 +146,7 @@ describe("migrateChart", () => {
it("migrates a legacy column chart to a Plotly column chart", () => {
expect(migrateChart(legacyColumnChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -172,6 +176,7 @@ describe("migrateChart", () => {
it("migrates a legacy bar chart to a Plotly bar chart", () => {
expect(migrateChart(legacyBarChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -201,6 +206,7 @@ describe("migrateChart", () => {
it("migrates a legacy pie chart to a Plotly pie chart", () => {
expect(migrateChart(legacyPieChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand All @@ -227,6 +233,7 @@ describe("migrateChart", () => {
it("migrates a legacy scatter plot to a Plotly scatter plot", () => {
expect(migrateChart(legacyScatterPlot, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"color": [
Expand Down Expand Up @@ -262,6 +269,7 @@ describe("migrateChart", () => {
it("migrates an empty chart widget to a plotly-line-chart", () => {
expect(migrateChart(emptyLegacyChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down
1 change: 1 addition & 0 deletions src/4.3_to_5.0/migrateChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export function migrateChart(
serverKey,
name: widgetName,
widgetKey: migratedWidgetKey,
areFiltersDrivenByMdx: true,
};

if (isUsingUnsupportedUpdateMode) {
Expand Down
4 changes: 3 additions & 1 deletion src/4.3_to_5.0/migrateDashboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("migrateDashboard", () => {
expect(dashboard.pages["p-0"].content).toMatchInlineSnapshot(`
{
"1": {
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand All @@ -36,7 +37,7 @@ describe("migrateDashboard", () => {
},
"name": "Tree table",
"query": {
"mdx": "SELECT NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM [EquityDerivativesCube] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS",
"mdx": "SELECT NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM (SELECT {[Currency].[Currency].[ALL].[AllMember].[GBP], [Currency].[Currency].[ALL].[AllMember].[JPY], [Currency].[Currency].[ALL].[AllMember].[USD]} ON COLUMNS FROM (SELECT TopCount(Filter([Geography].[City].Levels(1).Members, NOT IsEmpty([Measures].[contributors.COUNT])), 3, [Measures].[contributors.COUNT]) ON COLUMNS FROM [EquityDerivativesCube])) CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS",
"updateMode": "once",
},
"queryContext": [
Expand All @@ -57,6 +58,7 @@ describe("migrateDashboard", () => {
"widgetKey": "tree-table",
},
"2": {
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down
4 changes: 3 additions & 1 deletion src/4.3_to_5.0/migrateDrillthrough.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ describe("migrateDrillthrough", () => {
expect(migrateDrillthrough(legacyDrillthrough, servers))
.toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {},
"filters": [
"[Booking].[Desk].[ALL].[AllMember].[LegalEntityA].[BusinessUnitA]",
],
"name": "Drillthrough LegalEntityA ➜ BusinessUnitA",
"query": {
"mdx": "DRILLTHROUGH SELECT FROM [EquityDerivativesCube] RETURN MemberValue([BusinessUnit]), Caption([BusinessUnit]), MemberValue([TradeId]), Caption([TradeId])",
"mdx": "DRILLTHROUGH SELECT FROM [EquityDerivativesCube] WHERE [Booking].[Desk].[ALL].[AllMember].[LegalEntityA].[BusinessUnitA] RETURN MemberValue([BusinessUnit]), Caption([BusinessUnit]), MemberValue([TradeId]), Caption([TradeId])",
"updateMode": "once",
},
"queryContext": [],
Expand All @@ -28,6 +29,7 @@ describe("migrateDrillthrough", () => {
expect(migrateDrillthrough(emptyLegacyDrillthrough, servers))
.toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {},
"filters": [],
"name": "Untitled Drillthrough Table",
Expand Down
1 change: 1 addition & 0 deletions src/4.3_to_5.0/migrateDrillthrough.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function migrateDrillthrough(
serverKey,
widgetKey: "drillthrough-table",
columnWidths,
areFiltersDrivenByMdx: true,
};

const serializedWidgetState = serializeWidgetState(migratedWidgetState);
Expand Down
3 changes: 3 additions & 0 deletions src/4.3_to_5.0/migrateKpi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe("migrateKpi", () => {
it("returns the ActiveUI5 KPI widget state corresponding to the given ActiveUI4 KPI widget state", () => {
expect(migrateKpi(legacyKpi, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"columns": [],
Expand Down Expand Up @@ -46,6 +47,7 @@ describe("migrateKpi", () => {
it("migrates a KPI widget with a comparison", () => {
expect(migrateKpi(legacyComparisonValues, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"comparison": {
"comparedMemberNamePath": [
"AllMember",
Expand Down Expand Up @@ -83,6 +85,7 @@ describe("migrateKpi", () => {
it("migrates an empty KPI widget", () => {
expect(migrateKpi(emptyLegacyKpi, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"columns": [],
Expand Down
1 change: 1 addition & 0 deletions src/4.3_to_5.0/migrateKpi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export function migrateKpi(
name: legacyKpiState.name,
serverKey,
widgetKey: "kpi",
areFiltersDrivenByMdx: true,
};

const serializedWidgetState = serializeWidgetState(migratedWidgetState);
Expand Down
7 changes: 6 additions & 1 deletion src/4.3_to_5.0/migrateTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe("migrateTable", () => {
it("migrates a tree table widget", () => {
expect(migrateTable(legacyTreeTable, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand All @@ -37,7 +38,7 @@ describe("migrateTable", () => {
},
"name": "Tree table",
"query": {
"mdx": "SELECT NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM [EquityDerivativesCube] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS",
"mdx": "SELECT NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM (SELECT {[Currency].[Currency].[ALL].[AllMember].[GBP], [Currency].[Currency].[ALL].[AllMember].[JPY], [Currency].[Currency].[ALL].[AllMember].[USD]} ON COLUMNS FROM (SELECT TopCount(Filter([Geography].[City].Levels(1).Members, NOT IsEmpty([Measures].[contributors.COUNT])), 3, [Measures].[contributors.COUNT]) ON COLUMNS FROM [EquityDerivativesCube])) CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS",
"updateMode": "once",
},
"queryContext": [
Expand All @@ -63,6 +64,7 @@ describe("migrateTable", () => {
it("migrates an empty table widget", () => {
expect(migrateTable(emptyLegacyTable, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {},
"filters": [],
"mapping": {
Expand All @@ -86,6 +88,7 @@ describe("migrateTable", () => {
it("migrates a tabular view widget", () => {
expect(migrateTable(legacyTabularView, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand Down Expand Up @@ -114,6 +117,7 @@ describe("migrateTable", () => {
it("migrates a pivot table widget", () => {
expect(migrateTable(legacyPivotTable, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand Down Expand Up @@ -142,6 +146,7 @@ describe("migrateTable", () => {
it("migrates a table widget", () => {
expect(migrateTable(legacyTable, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand Down
1 change: 1 addition & 0 deletions src/4.3_to_5.0/migrateTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function migrateTable(
serverKey,
widgetKey: widgetPlugin.key,
columnWidths,
areFiltersDrivenByMdx: true,
};

const hiddenColumnKeys = _getHiddenColumnKeys(legacyTableState);
Expand Down
1 change: 1 addition & 0 deletions src/4.3_to_5.0/migrateWidget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("migrateWidget", () => {

expect(migrateWidget(legacyWidgetState, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down
2 changes: 1 addition & 1 deletion src/4.3_to_5.0/migrate_43_to_50.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe("migrate_43_to_50", () => {
"entry": {
"canRead": true,
"canWrite": true,
"content": "{"pages":{"p-0":{"layout":{"children":[{"leafKey":"2"},{"leafKey":"1"}],"direction":"row"},"name":"Page 1","filters":[],"content":{"1":{"serverUrl":"","mdx":"SELECT NON EMPTY Crossjoin(Hierarchize(DrilldownLevel([Geography].[City].[ALL].[AllMember])), Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember]))) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM [foo] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS","contextValues":{"mdx.hiddengrandtotals":"1"},"updateMode":"once","ranges":{"row":{"chunkSize":2000,"thresholdPercentage":0.1},"column":{"chunkSize":50,"thresholdPercentage":0.2}},"configuration":{"tabular":{"pinnedHeaderSelector":"member","sortingMode":"non-breaking","addButtonFilter":"numeric","cellRenderers":["tree-layout"],"statisticsShown":true,"columnsGroups":[{"captionProducer":"firstColumn","cellFactory":"kpi-status","selector":"kpi-status"},{"captionProducer":"firstColumn","cellFactory":"lookup","selector":"lookup"},{"captionProducer":"expiry","cellFactory":"expiry","selector":"kpi-expiry"},{"captionProducer":"columnMerge","cellFactory":{"args":{},"key":"treeCells"},"selector":"member"}],"hideAddButton":true,"defaultOptions":{},"expansion":{"automaticExpansion":true}}},"name":"Untitled Pivot Table","widgetKey":"pivot-table"},"2":{"switchedTo":"plotly-clustered-column-chart","mapping":{"xAxis":["[Currency].[Currency].[Currency]"],"values":["[Measures].[pnl.FOREX]"],"secondaryValues":[],"splitBy":["[Booking].[Desk].[LegalEntity]","ALL_MEASURES"],"horizontalSubplots":[],"verticalSubplots":[]},"query":{"mdx":"SELECT NON EMPTY Crossjoin(Hierarchize(DrilldownLevel([Currency].[Currency])), Hierarchize(DrilldownLevel([Booking].[Desk].[ALL].[AllMember]))) ON ROWS, NON EMPTY [Measures].[pnl.FOREX] ON COLUMNS FROM [EquityDerivativesCube]","updateMode":"once"},"filters":[],"queryContext":[],"serverKey":"my-server","name":"Untitled Chart","widgetKey":"plotly-line-chart"}},"queryContext":[]}},"pagesOrder":["p-0"],"filters":[],"queryContext":[]}",
"content": "{"pages":{"p-0":{"layout":{"children":[{"leafKey":"2"},{"leafKey":"1"}],"direction":"row"},"name":"Page 1","filters":[],"content":{"1":{"serverUrl":"","mdx":"SELECT NON EMPTY Crossjoin(Hierarchize(DrilldownLevel([Geography].[City].[ALL].[AllMember])), Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember]))) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM [foo] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS","contextValues":{"mdx.hiddengrandtotals":"1"},"updateMode":"once","ranges":{"row":{"chunkSize":2000,"thresholdPercentage":0.1},"column":{"chunkSize":50,"thresholdPercentage":0.2}},"configuration":{"tabular":{"pinnedHeaderSelector":"member","sortingMode":"non-breaking","addButtonFilter":"numeric","cellRenderers":["tree-layout"],"statisticsShown":true,"columnsGroups":[{"captionProducer":"firstColumn","cellFactory":"kpi-status","selector":"kpi-status"},{"captionProducer":"firstColumn","cellFactory":"lookup","selector":"lookup"},{"captionProducer":"expiry","cellFactory":"expiry","selector":"kpi-expiry"},{"captionProducer":"columnMerge","cellFactory":{"args":{},"key":"treeCells"},"selector":"member"}],"hideAddButton":true,"defaultOptions":{},"expansion":{"automaticExpansion":true}}},"name":"Untitled Pivot Table","widgetKey":"pivot-table"},"2":{"switchedTo":"plotly-clustered-column-chart","mapping":{"xAxis":["[Currency].[Currency].[Currency]"],"values":["[Measures].[pnl.FOREX]"],"secondaryValues":[],"splitBy":["[Booking].[Desk].[LegalEntity]","ALL_MEASURES"],"horizontalSubplots":[],"verticalSubplots":[]},"query":{"mdx":"SELECT NON EMPTY Crossjoin(Hierarchize(DrilldownLevel([Currency].[Currency])), Hierarchize(DrilldownLevel([Booking].[Desk].[ALL].[AllMember]))) ON ROWS, NON EMPTY [Measures].[pnl.FOREX] ON COLUMNS FROM [EquityDerivativesCube]","updateMode":"once"},"filters":[],"queryContext":[],"serverKey":"my-server","name":"Untitled Chart","widgetKey":"plotly-line-chart","areFiltersDrivenByMdx":true}},"queryContext":[]}},"pagesOrder":["p-0"],"filters":[],"queryContext":[]}",
"isDirectory": false,
"lastEditor": "admin",
"owners": [
Expand Down
Loading