Skip to content

refactor: small optimize for sql query #940

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

Merged
merged 2 commits into from
Feb 15, 2017
Merged

Conversation

appleboy
Copy link
Member

@appleboy appleboy commented Feb 15, 2017

  • Remove unused function RepositoriesWithUsers.
  • SQL improvement for repo.GetOwner loop condition.

cc @lunny

@appleboy appleboy changed the title feat: small optimize for sql query refactor: small optimize for sql query Feb 15, 2017
@lunny lunny added this to the 1.1.0 milestone Feb 15, 2017
@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Feb 15, 2017
@bkcsoft
Copy link
Member

bkcsoft commented Feb 15, 2017

If it compiles and runs you have my LGTM :)

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Feb 15, 2017
models/repo.go Outdated
if err = repos[i].GetOwner(); err != nil {
return nil, err
}
if err = repos.loadAttributes(x); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

But maybe sometime, we don't need to loadAttributes?

Copy link
Member Author

@appleboy appleboy Feb 15, 2017

Choose a reason for hiding this comment

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

Yes you're right. Ony two condition need to loadAttributes.

  1. Searcher is not nil.
  2. Star page of user profile

974dea2

Copy link
Member

@lunny lunny Feb 15, 2017

Choose a reason for hiding this comment

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

I prefer add a new field IfLoadAttributes bool for SearchRepoOptions. Then we can not hard code there.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot one place need to update.

See new commit: aa9fac1

We don't need a new field IfLoadAttributes, just two condition need GetOwner data:

opts.Searcher != nil || opts.Starred

Copy link
Member

Choose a reason for hiding this comment

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

OK.

models/repo.go Outdated
if err = repos.loadAttributes(x); err != nil {
return nil, 0, fmt.Errorf("LoadAttributes: %v", err)
}
if err = repos.loadAttributes(x); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Why always loadAttributes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! 974dea2

@appleboy appleboy force-pushed the sql3 branch 2 times, most recently from 105f4c3 to 974dea2 Compare February 15, 2017 02:05
@lunny
Copy link
Member

lunny commented Feb 15, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 15, 2017
@lunny lunny merged commit 9d2b830 into go-gitea:master Feb 15, 2017
@appleboy appleboy deleted the sql3 branch February 15, 2017 06:17
@Bwko Bwko mentioned this pull request Feb 15, 2017
1 task
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. 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.

4 participants