Skip to content

Commit

Permalink
Drop kpi titles that have an empty location.
Browse files Browse the repository at this point in the history
  • Loading branch information
NZepeda committed Jul 30, 2024
1 parent 620462a commit 88bab6b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/4.3_to_5.0/__snapshots__/migrate_43_to_50.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2502,7 +2502,7 @@ exports[`migrate_43_to_50 returns a valid ActiveUI5 /ui folder on a small input
"entry": {
"canRead": true,
"canWrite": true,
"content": "{"query":{"mdx":"SELECT NON EMPTY Hierarchize(AddCalculatedMembers(Descendants({[Geography].[City].[ALL].[AllMember]}, 1, SELF_AND_BEFORE))) ON ROWS, NON EMPTY {[Measures].[contributors.COUNT]} ON COLUMNS FROM [EquityDerivativesCube]","updateMode":"once"},"filters":["[Geography].[City].[ALL].[AllMember].[New York]"],"queryContext":[],"mapping":{"rows":["[Geography].[City].[City]"],"columns":[],"measures":["[Measures].[contributors.COUNT]"]},"serverKey":"my-server","titles":{"":"Title with empty location","[Measures].[contributors.COUNT]":"Custom title for contributors.COUNT"}}",
"content": "{"query":{"mdx":"SELECT NON EMPTY Hierarchize(AddCalculatedMembers(Descendants({[Geography].[City].[ALL].[AllMember]}, 1, SELF_AND_BEFORE))) ON ROWS, NON EMPTY {[Measures].[contributors.COUNT]} ON COLUMNS FROM [EquityDerivativesCube]","updateMode":"once"},"filters":["[Geography].[City].[ALL].[AllMember].[New York]"],"queryContext":[],"mapping":{"rows":["[Geography].[City].[City]"],"columns":[],"measures":["[Measures].[contributors.COUNT]"]},"serverKey":"my-server","titles":{"[Measures].[contributors.COUNT]":"Custom title for contributors.COUNT"}}",
"isDirectory": false,
"lastEditor": "admin",
"owners": [
Expand Down
1 change: 0 additions & 1 deletion src/4.3_to_5.0/getMigratedKpiTitles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe("getMigratedKpiTitles", () => {
});
expect(migratedKpiTitles).toMatchInlineSnapshot(`
{
"": "Empty measure title",
"[Measures].[contributors.COUNT],[Currency].[Currency].[AllMember].[EUR, USD]": "Hello World",
}
`);
Expand Down
18 changes: 10 additions & 8 deletions src/4.3_to_5.0/getMigratedKpiTitles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getMeasuresPositionOnAxis,
MdxSelect,
} from "@activeviam/mdx-5.0";
import _isEmpty from "lodash/isEmpty";

interface LegacyKpiTitle {
title: string;
Expand Down Expand Up @@ -65,7 +66,9 @@ function _getLegacyKpiTitles(
}
}

legacyTitles.push({ title, tuple });
if (!_isEmpty(tuple)) {
legacyTitles.push({ title, tuple });
}
}

return legacyTitles;
Expand Down Expand Up @@ -130,13 +133,12 @@ export function getMigratedKpiTitles(

if (measuresPositionInTuple > -1) {
const measureName = tuple[quote("Measures", "Measures")]?.[0];
if (measureName) {
memberUniqueNames.splice(
measuresPositionInTuple,
0,
quote("Measures", measureName),
);
}

memberUniqueNames.splice(
measuresPositionInTuple,
0,
quote("Measures", measureName),
);
}

const tupleKey = memberUniqueNames.join(",");
Expand Down
1 change: 0 additions & 1 deletion src/4.3_to_5.0/migrateKpi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe("migrateKpi", () => {
],
"serverKey": "my-server",
"titles": {
"": "Empty measure title",
"[Measures].[contributors.COUNT],[Currency].[Currency].[AllMember].[EUR, USD]": "Hello World",
},
"widgetKey": "kpi",
Expand Down
3 changes: 1 addition & 2 deletions src/migrateContentServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe("migrateContentServer", () => {
);
});

it("migrates custom titles for KPIs containing a blank measure in the mdx", async () => {
it("migrates the kpi custom titles when the original version contains a custom title with a tupleKey that is empty.", async () => {
const contentServer: ContentRecord = {
children: { ui: smallLegacyUIFolder, pivot: smallLegacyPivotFolder },
entry: {
Expand Down Expand Up @@ -266,7 +266,6 @@ describe("migrateContentServer", () => {

expect(migratedKpiContent?.titles).toMatchInlineSnapshot(`
{
"": "Title with empty location",
"[Measures].[contributors.COUNT]": "Custom title for contributors.COUNT",
}
`);
Expand Down

0 comments on commit 88bab6b

Please sign in to comment.