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-8742 - More robust MDX cleanup #115

Merged

Conversation

antoinetissier
Copy link
Collaborator

  • Bump to the latest versions of the SDK in order to benefit from the MDX changes implemented recently
  • In particular, use getIndexOfDeepestLevelExpressedInDescendantsNode which has been improved on the SDK side, and allows not to reinvent the wheel here
  • Add a try/catch around the different MDX cleanup steps, because they should not be blocking if they fail

@@ -60,7 +60,7 @@ describe("_cleanupDescendants", () => {
NON EMPTY Hierarchize(
Descendants(
{
[Booking].[Desk].[ALL].[AllMember].[LegalEntityA]
[Booking].[Desk].[ALL].[AllMember].[LegalEntityA].[BusinessUnitA].[DeskA].[0]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We were actually checking something invalid with the previous input:

Descendants(
              {
                [Booking].[Desk].[ALL].[AllMember].[LegalEntityA]
               },
               1
)

should NOT be replaced by just LegalEntityA.
Indeed the level at distance 1 from LegalEntityA is BusinessUnit.

However in the new test input:

Descendants(
              {
                [Booking].[Desk].[ALL].[AllMember].[LegalEntityA].[BusinessUnitA].[DeskA].[0]
               },
               1
)

the Descendants node should be replaced by the 0 BookId, since it doesn't have descendants anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we also keep a test for the LegalEntityA case which seems to have been broken but that you fixed in this PR (right?)


const levelsInSet = getLevels(set, {
cube,
}).filter((levelCorodinates) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}).filter((levelCorodinates) =>
}).filter((levelCoordinates) =>

@@ -17,15 +21,26 @@ const canDrilldownLevelBeReplacedByItsFirstArgument = (
drilldownLevelNode: MdxFunction,
cube: Cube,
) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function seems to have been improved in some cases. Don't clean up drilldownlevel if:

  • it has several arguments
  • something about the levels expressed in the set that are not on the same hierarchy as the first hierarchy found in the set (not sure what)

Can you add unit tests in order to illustrate and test these improvements?

Copy link
Collaborator Author

@antoinetissier antoinetissier Sep 26, 2023

Choose a reason for hiding this comment

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

Replace if both these conditions are met:

  • the function has a single argument
  • in the input set, the deepest level expressed in the first hierarchy (which is the one being implicitly drilled) is a leaf level

I'll add a comment.

@@ -60,7 +60,7 @@ describe("_cleanupDescendants", () => {
NON EMPTY Hierarchize(
Descendants(
{
[Booking].[Desk].[ALL].[AllMember].[LegalEntityA]
[Booking].[Desk].[ALL].[AllMember].[LegalEntityA].[BusinessUnitA].[DeskA].[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we also keep a test for the LegalEntityA case which seems to have been broken but that you fixed in this PR (right?)

@Nouzbe Nouzbe assigned antoinetissier and unassigned Nouzbe Sep 26, 2023
Copy link
Collaborator

@Nouzbe Nouzbe left a comment

Choose a reason for hiding this comment

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

Looks good 👍
You can consider this couple suggestions:

src/4.3_to_5.0/_cleanupDrilldownLevel.ts Outdated Show resolved Hide resolved
src/4.3_to_5.0/_cleanupDrilldownLevel.ts Outdated Show resolved Hide resolved
@Nouzbe Nouzbe assigned antoinetissier and unassigned Nouzbe Sep 26, 2023
@antoinetissier antoinetissier merged commit 0a8d012 into main Sep 26, 2023
1 check passed
@antoinetissier antoinetissier deleted the personal/a.tissier/UI-8742-more-robust-mdx-cleanup branch September 26, 2023 14:01
@antoinetissier antoinetissier added the enhancement New feature or request label Sep 26, 2023
mingkongwoo added a commit that referenced this pull request Sep 29, 2023
* UI-8742 - More robust MDX cleanup

* Bump to latest versions of the SDK

* add robustness

* format test snapshot

* PR feedback

* Update src/4.3_to_5.0/_cleanupDrilldownLevel.ts

Co-authored-by: Benjamin Amelot <[email protected]>

* Update src/4.3_to_5.0/_cleanupDrilldownLevel.ts

Co-authored-by: Benjamin Amelot <[email protected]>

---------

Co-authored-by: Benjamin Amelot <[email protected]>
mingkongwoo added a commit that referenced this pull request Sep 29, 2023
mingkongwoo added a commit that referenced this pull request Oct 2, 2023
* UI-8742 - More robust MDX cleanup

* Bump to latest versions of the SDK

* add robustness

* format test snapshot

* PR feedback

* Update src/4.3_to_5.0/_cleanupDrilldownLevel.ts

Co-authored-by: Benjamin Amelot <[email protected]>

* Update src/4.3_to_5.0/_cleanupDrilldownLevel.ts

Co-authored-by: Benjamin Amelot <[email protected]>

---------

Co-authored-by: Benjamin Amelot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants