-
Notifications
You must be signed in to change notification settings - Fork 32
chore: refactor findOneComplete to avoid dup #2236
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
Conversation
66439f5 to
46f029c
Compare
|
Looks good to me! Great to avoid duplicated functionality. (However, I don't fully understand the consequences of your type changes, so I'll let someone else approve) |
HayenNico
left a comment
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.
All type changes look good, but I had a couple questions (see below).
This also conflicts with fixes to findOneComplete in #2212 so we need to pick an approach
In principle my PR (a part from the defaults use case that I'll address) only reuses findAllComplete in findOneComplete. This avoids duplication and is conceptually more consistent I think as findOneComplete is just a special case of the findAllComplete. I also think is more intuitive for the user that the 2 endpoints work the same. The difference was only the order of the project stage, which in findOne was applied before the relation, thus I had to change the test. I think for a user this would not make sense. If I ask for the "instrument" relation and then don't include "instrument" in the fields it is expected I believe "instruments" will not be there. So I would lean towards my PR (a bit biased :) ), as a start and then apply the changes from #2212 as I added in the comment there |
|
If the findOneComplete query can be done with the findAllComplete query, I don’t see why we need it at all. |
|
it's just a utility that sets the filters and this allows me not to change where findOneComplete was historically used. I am not sure why this was ever implemented, but if you follow the old logic (or check the changes of this PR), it does exactly the same. BTW the add Since it's a findOne and not findById, it does not set the ID. I agree the findById could reuse this. When reading the code, I think it would be way easier if for every controller, for the GETs we had essentially 1 function in service reused in all controllers, i.e. this findAllComplete with |
I'm on board with this refactor, but I think at least part of #2212 (the bugfix for @nitrosx @Junjiequan @abdimo101 Do you think it would be better to split #2212 into two PRs, one for the |
|
@HayenNico @nitrosx @abdimo101 I think it's better to merge the PR with bug fix (use correct lookup sequence for all controllers), add corresponding tests and then open an issue to discuss enhanced include logic later on |
d4a04da to
7d6a079
Compare
|
@Junjiequan , @HayenNico @abdimo101 , sorry for the wait, I was carried away... I should have addressed the comments and this is only a rebase now that @abdimo101 has fixed the includes issue |
HayenNico
left a comment
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.
Looks good 👍
Description
Avoids logic duplication and reuses existing more generic function
Changes:
Tests included
Documentation
official documentation info