feat(repo): support search repository by topic name (#4505)

* feat(repo): support search repository by topic name
This commit is contained in:
Bo-Yi Wu 2018-09-13 10:33:48 +08:00 committed by GitHub
parent 7dd93b2441
commit ea20adaa84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 134 additions and 26 deletions

View file

@ -91,6 +91,7 @@ func Search(ctx *context.APIContext) {
OwnerID: ctx.QueryInt64("uid"),
Page: ctx.QueryInt("page"),
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
TopicOnly: ctx.QueryBool("topic"),
Collaborate: util.OptionalBoolNone,
}

View file

@ -122,6 +122,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
}
keyword := strings.Trim(ctx.Query("q"), " ")
topicOnly := ctx.QueryBool("topic")
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
Page: page,
@ -131,6 +132,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
Keyword: keyword,
OwnerID: opts.OwnerID,
AllPublic: true,
TopicOnly: topicOnly,
})
if err != nil {
ctx.ServerError("SearchRepositoryByName", err)

View file

@ -105,6 +105,8 @@ func Profile(ctx *context.Context) {
page = 1
}
topicOnly := ctx.QueryBool("topic")
var (
repos []*models.Repository
count int64
@ -174,6 +176,7 @@ func Profile(ctx *context.Context) {
PageSize: setting.UI.User.RepoPagingNum,
Starred: true,
Collaborate: util.OptionalBoolFalse,
TopicOnly: topicOnly,
})
if err != nil {
ctx.ServerError("SearchRepositoryByName", err)
@ -217,6 +220,7 @@ func Profile(ctx *context.Context) {
IsProfile: true,
PageSize: setting.UI.User.RepoPagingNum,
Collaborate: util.OptionalBoolFalse,
TopicOnly: topicOnly,
})
if err != nil {
ctx.ServerError("SearchRepositoryByName", err)