-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Conversation
If it compiles and runs you have my LGTM :) |
models/repo.go
Outdated
if err = repos[i].GetOwner(); err != nil { | ||
return nil, err | ||
} | ||
if err = repos.loadAttributes(x); err != nil { |
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.
But maybe sometime, we don't need to loadAttributes
?
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.
Yes you're right. Ony two condition need to loadAttributes
.
Searcher
is not nil.- Star page of user profile
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.
I prefer add a new field IfLoadAttributes bool
for SearchRepoOptions
. Then we can not hard code there.
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.
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
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.
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 { |
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.
Why always loadAttributes?
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.
Done! 974dea2
105f4c3
to
974dea2
Compare
LGTM |
RepositoriesWithUsers
.repo.GetOwner
loop condition.cc @lunny