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-9249 - Migrate default selected drillthrough columns #123

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ exports[`migrateSettingsFolder returns the folders corresponding to the converte
},
"settings": {
"entry": {
"content": "{"userFilters.areEnabled":false}",
"content": "{"userFilters.areEnabled":false,"drillthrough.defaultSelectedColumns":{"MarketRiskCube":["riskCurrency","subTradeId","EntityName"],"SecondCube":["delta"]}}",
"owners": [
"user1",
],
Expand Down
4 changes: 2 additions & 2 deletions 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 @@ -1277,7 +1277,7 @@ exports[`migrate_43_to_50 returns a valid ActiveUI5 /ui folder on a real life in
},
"settings": {
"entry": {
"content": "{"userFilters.areEnabled":false}",
"content": "{"userFilters.areEnabled":false,"drillthrough.defaultSelectedColumns":{"MarketRiskCube":["riskCurrency","subTradeId","EntityName"],"SecondCube":["delta"]}}",
"owners": [
"user1",
],
Expand Down Expand Up @@ -2420,7 +2420,7 @@ exports[`migrate_43_to_50 returns a valid ActiveUI5 /ui folder on a small input
},
"settings": {
"entry": {
"content": "{"theme":"dark-activeviam","search.maxResults":10,"userFilters.areEnabled":true}",
"content": "{"theme":"dark-activeviam","search.maxResults":10,"userFilters.areEnabled":true,"drillthrough.defaultSelectedColumns":{"EquityDerivativesCube":["delta","gamma","pnlVega","Desk","Currency","Date","HostName"],"EquityDerivativesCubeDist":["BumpedMtmDown","ProductQtyMultiplier","vega","rho","productId","pnlVega","pnlDelta","pnl","gamma","delta","TradeId","ProductBaseMtm"]}}",
"owners": [
"admin",
],
Expand Down
52 changes: 52 additions & 0 deletions src/4.3_to_5.0/legacySettingsFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,58 @@ const user1Preferences = {
deny: [],
map: {
"userFilters.enabled": true,
"widgets.Tabular.drillthrough.selectedColumns": {
"https://activerisk.zone1.scb.net:8081/server": {
MarketRiskCube: [
{
functionName: "MemberValue",
columnName: "riskCurrency",
},
{
functionName: "Caption",
columnName: "riskCurrency",
},
{
functionName: "MemberValue",
columnName: "subTradeId",
},
{
functionName: "Caption",
columnName: "subTradeId",
},
],
SecondCube: [
{
functionName: "MemberValue",
columnName: "delta",
},
{
functionName: "Caption",
columnName: "delta",
},
Comment on lines +38 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is considered duplicates, so we are testing that part of the implementation ?

Copy link
Collaborator Author

@Nouzbe Nouzbe Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is considered duplicates indeed. It's the first way to have duplicate I described above.

I also tested the second way of having duplicates, as I added the column subTradeId in MarketRiskCube under two different servers.

],
},
"https://second-server.com": {
MarketRiskCube: [
{
functionName: "MemberValue",
columnName: "subTradeId",
},
{
functionName: "Caption",
columnName: "subTradeId",
},
{
functionName: "MemberValue",
columnName: "EntityName",
},
{
functionName: "Caption",
columnName: "EntityName",
},
],
},
},
},
};

Expand Down
38 changes: 38 additions & 0 deletions src/4.3_to_5.0/migrateSettingsFolder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _cloneDeep from "lodash/cloneDeep";
import _mapValues from "lodash/mapValues";
import _uniq from "lodash/uniq";
import _pick from "lodash/pick";
import type {
Activity,
Expand Down Expand Up @@ -38,6 +39,43 @@ function migrateSettingsMap(legacySettingsMap: {
migratedSettingsMap["userFilters.areEnabled"] = areUserFiltersEnabled;
}

const legacyDrillthroughColumns:
| {
[serverUrl: string]: {
[cubeName: string]: {
functionName: "Value" | "Caption" | "MemberValue" | "MemberCaption";
columnName: string;
}[];
};
}
| undefined =
legacySettingsMap["widgets.Tabular.drillthrough.selectedColumns"];

if (legacyDrillthroughColumns !== undefined) {
const migratedDrillthroughColumns: Settings["drillthrough.defaultSelectedColumns"] =
{};
// The legacy settings are per server and per cube.
// The new ones are only per cube: the assumption is that no customer has multiple servers containing a cube with the same name but exposing a different data model.
for (const serverUrl in legacyDrillthroughColumns) {
for (const cubeName in legacyDrillthroughColumns[serverUrl]) {
if (migratedDrillthroughColumns[cubeName] === undefined) {
migratedDrillthroughColumns[cubeName] = [];
}
migratedDrillthroughColumns[cubeName].push(
...legacyDrillthroughColumns[serverUrl][cubeName].map(
({ columnName }) => columnName,
),
);
}
}

// Remove duplicates.
migratedSettingsMap["drillthrough.defaultSelectedColumns"] = _mapValues(
migratedDrillthroughColumns,
_uniq,
);
}
Comment on lines +72 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies that two drillthrough columns with the same columnName but different functionName are considered duplicates. Right ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. In fact there are even two ways to have duplicates:

  • because UI4 was typically storing the following for each column:
{
  functionName: "MemberValue",
  columnName: "myColumn",
}, {
  functionName: "MemberCaption",
  columnName: "myColumn"
}

So we don't want to save each column twice in the new Atoti UI 5 setting.

The other way is more rare. It is because UI4 was saving the columns per server and per cube whereas UI5 only stores them per cube. So you could have a duplicate because a column was save for a cube with the same name under two different servers.

The current implementation in this PR should get rid of any duplicate, whether they come from the first way or the second one I described here.


return migratedSettingsMap;
}

Expand Down
Loading