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

Refactor reuse some simple db.SearchOrderBy #25863

Closed

Conversation

CaiCandong
Copy link
Member

@CaiCandong CaiCandong commented Jul 13, 2023

As @yp05327 suggested in #25808 , we should use db.SearchOrderBy instead of sortType whenever possible. Considering that db.SearchOrderBy can't cover all the complex sorting logic possible, I've made a simple modification to the implementation in improve in #25806.
related #25806
close #25808

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 13, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 13, 2023
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jul 13, 2023

I do not think it right to add more "db.SearchOrderXxx", it's an over-design/over-abstraction.

In the end, every model/table should have their own "order rules", but not using the shared unclear one.

@wxiaoguang
Copy link
Contributor

The over-designed/over-abstracted shared constants / shared templates already causes problems like #14947

@CaiCandong
Copy link
Member Author

I do not think it right to add more "db.SearchOrderXxx", it's an over-design/over-abstraction.

In the end, every model/table should have its own "order rules", but not use the shared unclear one.

I also think that having the same "order rules" common to every model/table is a bit of over-design, so I somehow backed out the improve in #25806 in my implementation.

While keeping each model/table independent, reusing some simple sorting rules can also reduce the possibility of errors. I think there is a trade-off between reuse and independence.

Maybe I should change the title of this PR.

@CaiCandong CaiCandong changed the title Refactor reuse db.SearchOrderBy as much as possible. Refactor reuse some simple db.SearchOrderBy Jul 13, 2023
@yp05327
Copy link
Contributor

yp05327 commented Jul 14, 2023

Maybe we can design a global shareable order rules, like the usage of db.SearchOrderByXXX now.
And for each model/table they have their own "order rules", and some of these rules can reference the globally shared order rules.
Then we can avoid over-design and some simple mistakes like #25806.

ps: We have this simple logic mistake for over 3 years, but no one notice it.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Jul 14, 2023
@lunny lunny added this to the 1.21.0 milestone Jul 14, 2023
@CaiCandong CaiCandong closed this Aug 1, 2023
@GiteaBot GiteaBot removed this from the 1.21.0 milestone Aug 1, 2023
@CaiCandong CaiCandong deleted the refactor-sortType-to-SearchOrderBy branch August 2, 2023 05:13
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using db.SearchOrderBy in internal instead of sortType
5 participants