-
Notifications
You must be signed in to change notification settings - Fork 1
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-9566 - Ensure a best effort migration of the KPI titles even when some titles could not be successfully migrated. #129
UI-9566 - Ensure a best effort migration of the KPI titles even when some titles could not be successfully migrated. #129
Conversation
…e the titles migrated.
"": { | ||
title: "Empty measure title", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this fix, I went with dropping titles that have an empty tuple key and ensuring the rest of the titles are still migrated. However, I'm not 100% sure how one can even land in this state. It doesn't seem like it's valid so I dropped it, but if it is better to ensure this kind of custom title is supported, I can adapt the change to ensure it's also migrated.
…hub.com:activeviam/atoti-ui-migration into task/nze/UI-9566-support-migrating-empty-titles
…is an error while migrating one of the titles the succesfully migrated titles should still be persisted.
if (memberUniqueName) { | ||
const compoundIdentifier = | ||
parse<MdxUnknownCompoundIdentifier>(memberUniqueName); | ||
const specificCompoundIdentifier = getSpecificCompoundIdentifier( | ||
compoundIdentifier, | ||
{ cube }, | ||
); | ||
tuple[hierarchyUniqueName] = specificCompoundIdentifier.path; | ||
if (specificCompoundIdentifier.type === "measure") { | ||
tuple[`[Measures].[Measures]`] = [ | ||
specificCompoundIdentifier.measureName, | ||
]; | ||
} else if (specificCompoundIdentifier.type === "member") { | ||
const hierarchyUniqueName = quote( | ||
specificCompoundIdentifier.dimensionName, | ||
specificCompoundIdentifier.hierarchyName, | ||
); | ||
tuple[hierarchyUniqueName] = specificCompoundIdentifier.path; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a big change but all I did was wrap this logic block in an if
statement.
try { | ||
const memberUniqueNames: string[] = []; | ||
|
||
ordinalFields.forEach((field) => { | ||
if (field.type === "hierarchy") { | ||
const hierarchyUniqueName = quote( | ||
field.dimensionName, | ||
field.hierarchyName, | ||
); | ||
const namePath = tuple[hierarchyUniqueName]; | ||
if (namePath) { | ||
memberUniqueNames.push( | ||
`${hierarchyUniqueName}.${quote(...namePath)}`, | ||
ordinalFields.forEach((field) => { | ||
if (field.type === "hierarchy") { | ||
const hierarchyUniqueName = quote( | ||
field.dimensionName, | ||
field.hierarchyName, | ||
); | ||
const namePath = tuple[hierarchyUniqueName]; | ||
if (namePath) { | ||
memberUniqueNames.push( | ||
`${hierarchyUniqueName}.${quote(...namePath)}`, | ||
); | ||
} | ||
} | ||
}); | ||
|
||
if (measuresPositionInTuple > -1) { | ||
const measureName = tuple[quote("Measures", "Measures")][0]; | ||
memberUniqueNames.splice( | ||
measuresPositionInTuple, | ||
0, | ||
quote("Measures", measureName), | ||
); | ||
} | ||
}); | ||
|
||
if (measuresPositionInTuple > -1) { | ||
const measureName = tuple[quote("Measures", "Measures")][0]; | ||
memberUniqueNames.splice( | ||
measuresPositionInTuple, | ||
0, | ||
quote("Measures", measureName), | ||
); | ||
} | ||
|
||
const tupleKey = memberUniqueNames.join(","); | ||
migratedTitles[tupleKey] = title; | ||
const tupleKey = memberUniqueNames.join(","); | ||
migratedTitles[tupleKey] = title; | ||
} catch (error) { | ||
errors.push(error as Error); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, looks like a big change but I just wrapped this logic block in a try-catch.
if (errors.length > 0) { | ||
throw new Error( | ||
`One or more errors occurred while migrating the titles for the kpi named ${legacyKpiState.name}: ` + | ||
errors.map((e) => e.message).join(", "), | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function "swallows" any error until all legacyTitles
have been attempted to be migrated. This throws at the end to ensure that the kpi widget that is being migrated is marked as partially migrated
.
…hub.com:activeviam/atoti-ui-migration into task/nze/UI-9566-support-migrating-empty-titles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please merge #128 into main, rebase this branch and take the following comment into consideration before reassigning?
* The shortened version of the content of the /ui folder on a Content Server, useful for unit tests. | ||
* Contains a KPI widget containing a custom title with an empty `tupleKey` for its location. | ||
*/ | ||
export const smallLegacyUIFolderWithInvalidKpiTitle = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to factorize the common part between this and the test resource introduced in #128, in order to avoid adding redundant content to this repo.
For instance, we could have a emptyLegacyUIFolder
test resource and a addLegacyBookmarkToUIFolder
test resource function that takes a map of id to legacy bookmark as argument and returns the "small legacy UI folder with ..." object, without mutating emptyLegacyFolder
.
…n test resource files
…UI folder function
This is done via one of the latest commits 🫡 |
@Nouzbe Your latest suggestions have been addressed in the latest commits 👍 |
src/4.3_to_5.0/__test_resources__/legacyUIFolderWithInvalidKpi.ts
Outdated
Show resolved
Hide resolved
src/4.3_to_5.0/__test_resources__/legacyInvalidDashboardBookmark.ts
Outdated
Show resolved
Hide resolved
src/4.3_to_5.0/__test_resources__/legacyInvalidFilterBookmark.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The KPI titles change looks good. The test resources refactor looks good too. There's just a couple instances where we've lost some content in our snapshots (I assume because we've lost them in some test resources). See comments below.
Otherwise, good to go!
}, | ||
"settings": { | ||
"entry": { | ||
"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"]}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, it looks like we're losing the settings conversion part of this test snapshot. It's probably because some settings that were part of a legacy UI folder test resource were lost in the process. Can you please make sure that we don't lose this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a new commit to avoid losing this information. However, it means re-adding the settings
to the emptyLegacyUIFolder
since we are now generating test resources such as smallLegacyUIFolder
via the emptyLegacyUIFolder
and addLegacyBookmarkToUIFolder
.
@@ -2247,12 +2247,8 @@ exports[`migrate_43_to_50 returns a valid ActiveUI5 /ui folder on a small input | |||
"content": "{"name":"hidden grand totals"}", | |||
"isDirectory": true, | |||
"lastEditor": "admin", | |||
"owners": [ | |||
"admin", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too, it would be nice to not lose this, in order to ensure that the migration script does not erase bookmark permissions.
}); | ||
if (migratedTitles && Object.keys(migratedTitles).length > 0) { | ||
migratedWidgetState.titles = migratedTitles; | ||
} | ||
} | ||
} catch (error) { | ||
// Migrating the KPI titles is a best effort. | ||
// If there is an error while migrating one of the titles, the successfully migrated titles are still persisted. | ||
if (migratedTitles && Object.keys(migratedTitles).length > 0) { | ||
migratedWidgetState.titles = migratedTitles; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it now, thank you 👍
@@ -2397,6 +2404,86 @@ exports[`migrate_43_to_50 returns a valid ActiveUI5 /ui folder on a small input | |||
}, | |||
}, | |||
"users": { | |||
"children": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change results from re-adding the settings
to the emptyLegacyUIFolder
. With the changes in this commit, this file remains unchanged in this PR.
@Nouzbe With the latest commit, I've ensured that we are not losing any data in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A different approach could be to have a addLegacySettings
function, which adds given settings to a legacy UI folder. This way, smallLegacyUIFolder
could be generated from an actually empty emptyLegacyUIFolder
using this function.
If you like this way better, I'll leave it up to you if you prefer to do it in this PR or separately.
This is good to go, thank you for bearing with me 👍
I'll address this in a separate PR 👍 |
Summary
Issue
As the ticket states, when migrating KPIs containing custom titles, if the migration of one of the titles throws an error, none of the custom titles are migrated.
On this specific ticket, the issue was that when the KPI contained a title with an empty
tupleKey
as seen below, the process would error out resulting in none of the titles (even the valid ones) being migrated.Solution
This PR aims to improve on that by ensuring that even if there is an error, the successfully migrated titles are persisted and the
KPI
widget is marked asPartially migrated
.Corresponding ticket: https://activeviam.atlassian.net/browse/UI-9566
Reviewing
Ensure the new and updated tests make sense