-
- Notifications
You must be signed in to change notification settings - Fork 6.2k
Add repository type option to /api/repo/search #2326
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
Add repository type option to /api/repo/search #2326
Conversation
models/repo_list.go Outdated
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.
Missing comments for type and constants below
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.
Comments added
c0a0ada
to 9a50260
Compare Added some comments and rename |
9a50260
to 90e1e5b
Compare 90e1e5b
to 94f563b
Compare Can you add integration tests for this? |
@lafriks I can try. I have to learn what's in test db first and how to do it right. |
@lafriks I can't even run tests in gitea, so no... |
8cc9ea4
to 4ad515f
Compare Rebased on master |
4ad515f
to e07d6e2
Compare e07d6e2
to 43b77fe
Compare f4cc1bb
to 144c507
Compare Codecov Report
@@ Coverage Diff @@ ## master #2326 +/- ## ========================================== + Coverage 27.32% 27.61% +0.28% ========================================== Files 86 86 Lines 17135 17112 -23 ========================================== + Hits 4682 4725 +43 + Misses 11775 11709 -66 Partials 678 678
Continue to review full report at Codecov.
|
Rebased on top of #2371. Only last commit is new. I'll create new tests for added feature soon. |
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 my thoughts ;-)
And is the huge amount of new test data really necessary for your tests?
models/repo_list.go Outdated
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.
IMO includeStarred
is misleading as it doesn't include starred, it restricts to starred repositories.
Suggest changing to something like includeOnlyStarred
!?
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 think this part is only about adding/joining "starred" table to SQL. It doesn't restrict anything. Maybe renaming it to includeStarredTable
or joinStarredTable
would be better.
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.
Inner join actually does restrict only to records that are in started table
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.
@lafriks True, I was thinking about left join in the future update... My mistake.
models/repo_list.go Outdated
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.
Doesn't this lead to an error if len(opts.OrderBy) == 0
evaluates to true as "id ASC".String()
does not exist?
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 think no. opts.OrderBy
is custom type SearchOrderBy
, you can't pass just string and it can't be of zero length here, because there is check for that above:
if len(opts.OrderBy) == 0 { opts.OrderBy = SearchOrderByAlphabetically }
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 in https://github.com/Morlinest/gitea/blob/0baae9f69e2e54eb4d9fb3329b188f5f9a88bcd9/models/repo_list.go#L275
you it gets set to "id ASC"
before calling .String()
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.
You are right, I was looking at other place... Answer: It will not fail :). You can put any string there.
routers/home.go Outdated
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.
AFAIK Ranger
is not needed anymore and can be generally be removed from RepoSearchOptions and thus at
Line 27 in 566e8ec
Ranger: models.Repositories, |
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.
integrations/api_repo_test.go Outdated
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.
This test should also be added to your testCases list
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 am thinking (last few days) about extracting this change to new PR because actually it's fix for non working test.
models/repo_list_test.go Outdated
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.
Add existing tests to testCases.
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 don't want to do it in this (#2371) PR because:
- I want to show my PR will pass existing tests without changes
- For moving existing tests to my added test cases it would be needed fixes at least in "repository.yml" and "access.yml".
0baae9f
to 2c8263c
Compare 2c8263c
to 19c15bb
Compare @Morlinest why close this PR? |
First attempt to solve #2321. I want to check, if this way is OK.