Skip to content

Use a sql recursive query for node tree invalidation and dto tree building #791

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

Merged
merged 6 commits into from
Jul 2, 2025

Conversation

SlimaneAmar
Copy link
Contributor

No description provided.

Copy link
Contributor

@klesaulnier klesaulnier left a comment

Choose a reason for hiding this comment

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

Small remarks

Test: OK

"FROM NodeHierarchy nh " +
"ORDER BY nh.depth DESC")
List<String> findAllDescendants(UUID nodeUuid);
"SELECT cast(nh.id_node AS VARCHAR) " +
Copy link
Contributor

Choose a reason for hiding this comment

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

is "cast()" needed here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes otherwise the result is of type string and not uuid

Copy link
Contributor

Choose a reason for hiding this comment

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

does it work without casting neither in postgres nor H2? or not working only in H2?

return nodesRepository.findAllChildrenUuids(parentUuid);
}

// TODO Remove this method and use getAllChildrenUuids
Copy link
Contributor

Choose a reason for hiding this comment

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

since we've already changed some "getChildren" to "getChildrenUuids" here, why don't we make this change right now by renaming all occurences ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is used in many places and you have to test a lot of things
A TS was created

@@ -598,7 +598,7 @@ void testNodeModificationInfos() throws Exception {

List<AbstractNode> children = root.getChildren();
assertEquals(2, children.size());
NetworkModificationNode n1 = (NetworkModificationNode) children.get(0);
NetworkModificationNode n1 = (NetworkModificationNode) (children.get(0).getName().equals("n1") ? children.get(0) : children.get(1));
Copy link
Contributor

Choose a reason for hiding this comment

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

we could replace by .stream().findFirst by name instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

*/
assertChildrenEquals(Set.of(node1, node2), root.getChildren());

node2.setName("niark");
node1.setName("condriak");
node1.setModificationGroupUuid(UUID.randomUUID());
createNode(root.getStudyId(), children.get(1), node2, userId);
createNode(root.getStudyId(), children.get(1), node1, userId);
AbstractNode child = children.get(0).getName().equals("loadflow") ? children.get(0) : children.get(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

" FROM NODE n " +
" INNER JOIN NodeHierarchy nh ON n.parent_node = nh.id_node " +
") " +
"SELECT nh.id_node::text " +
"FROM NodeHierarchy nh " +
"ORDER BY nh.depth DESC")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that ordering by depth was not necessary anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@SlimaneAmar SlimaneAmar force-pushed the use_sql_recursive_for_node_tree_invalidation branch from a545215 to d62860d Compare June 30, 2025 11:20
Copy link

Copy link
Contributor

@antoinebhs antoinebhs left a comment

Choose a reason for hiding this comment

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

Code OK

@SlimaneAmar SlimaneAmar merged commit 593af5d into main Jul 2, 2025
4 checks passed
@SlimaneAmar SlimaneAmar deleted the use_sql_recursive_for_node_tree_invalidation branch July 2, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants