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

Field of law improvements #2342

Merged
merged 64 commits into from
Nov 27, 2024
Merged

Field of law improvements #2342

merged 64 commits into from
Nov 27, 2024

Conversation

elaydis
Copy link
Contributor

@elaydis elaydis commented Nov 6, 2024

RISDEV-5342

@elaydis elaydis added the dev-env Automatically spins up developer environment label Nov 6, 2024
@kiwikern kiwikern self-requested a review November 27, 2024 10:21
Copy link
Contributor

@kiwikern kiwikern left a comment

Choose a reason for hiding this comment

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

@elaydis @leonie-koch Wow, I am very impressed! This is such a huge improvement, using this component feels great. Great job! 👏 I left a lot of comments, feel free to resolve them without comment/explanation if not relevant. :-)

frontend/src/components/field-of-law/FieldsOfLaw.vue Outdated Show resolved Hide resolved
frontend/src/components/field-of-law/FieldsOfLaw.vue Outdated Show resolved Hide resolved
frontend/src/components/field-of-law/FieldOfLawSummary.vue Outdated Show resolved Hide resolved
@@ -88,14 +88,14 @@ public List<FieldOfLaw> findBySearchTerms(String[] searchTerms) {
}

return listWithFirstSearchTerm.stream()
.filter(fieldOfLawDTO -> returnTrueIfInTextOrIdentifier(fieldOfLawDTO, searchTerms))
.filter(fieldOfLawDTO -> returnTrueIfInText(fieldOfLawDTO, searchTerms))
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Why do we query the database with only one search term instead of all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm not sure if I understand the question correctly 🤔 you mean write a query that directly queries with identifier and text combined in the database?

Copy link
Contributor

Choose a reason for hiding this comment

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

Above we query the database with only the first searchTerm:

repository.findAllByNotationAndIdentifierContainingIgnoreCaseOrTextContainingIgnoreCase(
            searchTerms[0])

Then we filter the results in memory.

An alternative would be to directly filter for multiple searchTerms in the database (the same we do for the first search term, but for each term and then connected via AND)

Copy link
Contributor

Choose a reason for hiding this comment

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

I just checkend and apparently the jpa method name magic does not support arrays, so you would need either native SQL or better use the Criteria API. -> The same as comment above, we can ignore this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

💡 thanks for checking this! criteria API sounds really promising

@@ -18,9 +18,16 @@ public interface FieldOfLawRepository {

List<FieldOfLaw> findBySearchTerms(String[] searchTerms);

List<FieldOfLaw> findByNormStr(String normStr);
List<FieldOfLaw> findByNorm(String normStr);
Copy link
Contributor

Choose a reason for hiding this comment

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

non-blocking idea: Instead of having specific methods for all, write one method with the criteriaAPI and dynamically construct the query with the search parameters that are present.

@elaydis
Copy link
Contributor Author

elaydis commented Nov 27, 2024

@kiwikern again thank you so much for taking the time and leaving all those helpful comments 🫶 I will merge now and look into improving the backend tomorrow so that users already get the new experience they were promised ☺️

@elaydis elaydis merged commit 0145335 into main Nov 27, 2024
26 checks passed
@elaydis elaydis deleted the field-of-law branch November 27, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-env Automatically spins up developer environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants