-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fixing searchAndCount searchAndDistinctCount when sc is null #4374
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
b4de2a4 to
a430bf6
Compare
a430bf6 to
120ee25
Compare
|
@blueorangutan package |
|
@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2118 |
|
@blueorangutan test |
|
@davidjumani a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
DaanHoogland
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.
code looks good. I think the search and count method should however have a single set of criteria for both the results and the count and not need any adjustments down the line. starting with an sc only containing "true", could be a solution (as well or on top of this, no pref)
| @DB() | ||
| public <M> List<M> customSearch(SearchCriteria<M> sc, final Filter filter) { | ||
| if (_removed != null) { | ||
| sc.addAnd(_removed.second().field.getName(), SearchCriteria.Op.NULL); |
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.
can use checkAndSetRemovedIsNull() here ?
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.
Makes it a bit difficult since it is of a different type M not T
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.
ok @davidjumani
| } | ||
|
|
||
| public Integer getDistinctCount(SearchCriteria<T> sc, boolean removed) { | ||
| if (!removed) { |
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.
removed & _removed seems to be redundant here & wherever used in similar way, can you directly set / unset _removed as per its usage ? If the purpose is to include / exclude removed records, you can use methods with naming *IncludingRemovedBy() [for ex: getDistinctCountIncludingRemovedBy()] to be in sync with the other methods.
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.
As of now getDistinctCount returns including removed so changing it would require changing where it's been referenced, would it be better to create getDistinctCountExcludingRemoved ?
Edit : Nevermind. Isn't used much elsewhere. Will make the changes
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.
getDistinctCountExcludingRemoved is not in line with other methods, so I do not recommend.
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.
Default method should not include removed records, explicitly mentioned methods "*IncludingRemovedBy()" should. so, may be you can change current method to "*IncludingRemovedBy()" and add other method with current name.
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.
Added! Thanks @sureshanaparti
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.
Perfect, changes LGTM.
|
@blueorangutan package |
|
@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✖centos7 ✖centos8 ✔debian. JID-2125 |
|
@blueorangutan package |
|
@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2134 |
|
@blueorangutan test |
|
@davidjumani a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-2901)
|
|
@blueorangutan test matrix |
|
@davidjumani a Trillian-Jenkins matrix job (centos7 mgmt + xs71, centos7 mgmt + vmware67, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests |
|
Trillian test result (tid-2905)
|
|
@blueorangutan test centos7 xs71 |
|
@DaanHoogland unsupported parameters provided. Supported mgmt server os are: |
|
@blueorangutan test centos7 xenserver-71 |
|
@sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + xenserver-71) has been kicked to run smoke tests |
|
@blueorangutan test centos7 xenserver-71 |
|
@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + xenserver-71) has been kicked to run smoke tests |
|
Trillian test result (tid-2920)
|
|
@blueorangutan test centos7 kvm-centos7 |
|
@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-2926)
|
Description
Fixes #4372
Ensures that the count returned by searchAndCount searchAndDistinctCount do not include removed items
Before, it would return the count of removed items as well when the search criteria is null (since sc is created and modified in search which doesn't reflect when it tires to get the count)
Also refactored a bit to make life easieer for the next person who comes along
Types of changes
How Has This Been Tested?
Before :
After :