-
Notifications
You must be signed in to change notification settings - Fork 353
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
feat: limits for category combinations [DHIS2-18521] #19374
base: master
Are you sure you want to change the base?
Conversation
...is-test-web-api/src/test/java/org/hisp/dhis/test/webapi/H2ControllerIntegrationTestBase.java
Fixed
Show fixed
Hide fixed
...is-test-web-api/src/test/java/org/hisp/dhis/test/webapi/H2ControllerIntegrationTestBase.java
Fixed
Show fixed
Hide fixed
Quality Gate passedIssues Measures |
@@ -58,8 +59,10 @@ private DeletionVeto allowDeleteCategory(Category category) { | |||
} | |||
|
|||
private void deleteCategoryOptionCombo(CategoryOptionCombo categoryOptionCombo) { | |||
for (CategoryCombo categoryCombo : categoryService.getAllCategoryCombos()) { |
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.
FYI: I am not sure why we would loop over all CCs when there is just one linked to the COC which needs unlinking. Also I added a check if the un-linking isn't already done because if this was called as a consequence of deleting the CC it has and so the update should not be called again on the CC.
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.
If not needed, this is very nice. That could be very costly.
An existing/new test would confirm that.
@@ -69,6 +69,10 @@ public enum ErrorCode { | |||
|
|||
E1122("Category option combo {0} cannot be associated with the default category combo"), | |||
E1125("Category option combo {0} contains options not associated with category combo {1}"), | |||
E1126("Category combo {0} cannot combine more than {1} categories, but had: {2}"), | |||
E1127("Category {0} cannot have more than {1} options, but had: {2} "), | |||
E1128("Category combo {0} cannot have more than {1} combinations, bud requires: {2}"), |
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.
maybe this message can mirror the other 2?
..... cannot have more than x combinations, but had: y
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 sounds like a good idea, to have default limits for some items.
I'm wondering how this will play out in real use cases.
If a user tries to create more than the default, they will get the error message. Is the intention then that they should rethink how they are modelling things, but will most likely just update the config and get the higher limit they are looking for.
So it may just be an extra hoop they need to jump through (might be seen as annoying).
Summary
Adds 3 configurations for new limits around categories that are validated on create and update.
metadata.categories.max_options
: The maximum number of category options in a single categorymetadata.categories.max_per_combo
: The maximum number of categories per category combometadata.categories.max_combinations
: The maximum for the product of the number of options in a category comboAutomatic Testing
New controller tests added for each of the validations.
Manual Testing
Test limit max categories in a combo:
Test limit max options per category:
Test limit max combinations: