Skip to content

Conversation

appleboy
Copy link
Member

fix #1022

  • Remove counter function in RepoSearchOptions
  • Check IsAdmin Flag in search.

models/repo.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

It's not a good idea to copy Session. I think you can use cond?

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 e892404

models/repo.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

count, err := x.Where(cond).Cound(new(Repository))

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 e892404

@lunny lunny added this to the 1.1.0 milestone Feb 23, 2017
@lunny lunny added the type/enhancement An improvement of existing functionality label Feb 23, 2017
@lunny
Copy link
Member

lunny commented Feb 23, 2017

LGTM

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Feb 23, 2017
@lunny
Copy link
Member

lunny commented Feb 25, 2017

conflicted

@appleboy
Copy link
Member Author

fixed conflicts.

}

return repos, nil
count = countRepositories(-1, opts.Private)
Copy link
Member

Choose a reason for hiding this comment

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

Here, we check opts.Private to see if we should include private repos, but when populating the repos slice, we always include private repos regardless of opts.Private

Copy link
Member Author

Choose a reason for hiding this comment

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

Repositories always returns all repositories. maybe we need to change countRepositories(-1, true)?

Copy link
Member

Choose a reason for hiding this comment

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

If Repositories(..) always returns all repositories, I think it is misleading for it to take a SearchRepoOptions as a parameter, since it ignores most of the fields of opts.

Copy link
Member Author

@appleboy appleboy Feb 26, 2017

Choose a reason for hiding this comment

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

I can create another PR to refactor the codes according to your suggestion.

Copy link
Member

@ethantkoenig ethantkoenig Feb 26, 2017

Choose a reason for hiding this comment

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

Ok, I suppose I could do it too. Either way, it's outside the scope of this PR.


// Repositories returns all repositories
func Repositories(opts *SearchRepoOptions) (_ RepositoryList, err error) {
func Repositories(opts *SearchRepoOptions) (_ RepositoryList, count int64, err error) {
Copy link
Member

@ethantkoenig ethantkoenig Feb 26, 2017

Choose a reason for hiding this comment

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

EDITED: Why does this function not examine the contents of opts.Searcher, and exclude repos accordingly (like GetRecentUpdateRepositories(..)~)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I meant like GetRecentUpdateRepsitories(..); sorry if that caused any confusion.

Even if every codepath that calls Repositories(..) has opts.Searcher set to nil, someone might in the future add a changes that calls Repositories(..), have opts.Searcher not be nil, and expect Repositories to filter accordingly.

Copy link
Member

@ethantkoenig ethantkoenig Feb 26, 2017

Choose a reason for hiding this comment

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

Since Repositories(..) only looks at opts.PageSize, opts.Page, and opts.OrderBy, would it be better to have it take those 3 values as separate arguments?

Copy link
Member Author

Choose a reason for hiding this comment

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

NO. I think using SearchRepoOptions would be better than take 3 arguments if we want to extend the function.

Copy link
Member

@ethantkoenig ethantkoenig left a comment

Choose a reason for hiding this comment

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

LGTM

@ethantkoenig
Copy link
Member

LGTM

@appleboy
Copy link
Member Author

let L-G-T-M work @ethantkoenig Thanks for review this PR.

@appleboy
Copy link
Member Author

let L-G-T-M work

@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 26, 2017
@lunny lunny merged commit 95574a3 into go-gitea:master Feb 26, 2017
@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/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Admin can't see all private repositories on Explore page.
4 participants