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

Optimize SQL queries when getting tabular modification of generators #411

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -177,10 +177,10 @@ public List<ModificationInfos> getModificationsInfos(List<UUID> groupUuids, bool
Stream<ModificationEntity> modificationEntity = groupUuids.stream().flatMap(this::getModificationEntityStream);
if (onlyStashed) {
return modificationEntity.filter(m -> m.getStashed() == onlyStashed)
.map(ModificationEntity::toModificationInfos)
.map(this::getModificationInfos)
.collect(Collectors.toList());
} else {
return modificationEntity.map(ModificationEntity::toModificationInfos)
return modificationEntity.map(this::getModificationInfos)
.collect(Collectors.toList());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ public void testCheckSqlRequestsCount() throws Exception {
.andReturn();
// We check that the request count is not dependent on the number of sub modifications of the tabular modification (the JPA N+1 problem is correctly solved)
assertSelectCount(3);
reset();

// Now we get back the 2 tabular modifications
Copy link
Contributor

Choose a reason for hiding this comment

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

// We get the modification group

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just precised this to explain why we have 6 SELECT, but OK I change a bit the comment

mockMvc.perform(get("/v1/groups/{groupUuid}/network-modifications", getGroupId()))
.andExpect(status().isOk());
// We check that the request count is not dependent on the number of sub modifications of the tabular modification (the JPA N+1 problem is correctly solved)
assertSelectCount(6);
}

@Test
Expand Down
Loading