summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorDavid Svantesson <davidsvantesson@gmail.com>2019-08-25 19:06:36 +0200
committerLauris BH <lauris@nix.lv>2019-08-25 20:06:36 +0300
commitc9546d4cdd5f7de8f56b7d4a9806d1aca784cf3f (patch)
treeeebd4affa86ae9d75b41590453a07af42db31fb0 /routers/user
parent8c24bb9e4344791ca2e8c66efcf3d45881365a5d (diff)
downloadgitea-c9546d4cdd5f7de8f56b7d4a9806d1aca784cf3f.tar.gz
gitea-c9546d4cdd5f7de8f56b7d4a9806d1aca784cf3f.zip
Include description in repository search. (#7942)
* Add description in repository search. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Refactor SearchRepositoryByName with a general function SearchRepository Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Allow to specify if description shall be included in API repo search. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add new app.ini setting for whether to search within repo description. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Search keyword in description (if setting enabled) on: - Explore page - Organization profile page - User profile page - Admin repo page Do not search keyword in description on: - Any non-keyword search (not relevant) - Incremental search (uses API) Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Put parameters related to keyword directly after it Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add test cases for including (and not including) repository description in search. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Rename test function from TestSearchRepositoryByName to TestSearchRepository. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Make setting SEARCH_REPO_DESCRIPTION default to true Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/home.go23
-rw-r--r--routers/user/profile.go52
2 files changed, 39 insertions, 36 deletions
diff --git a/routers/user/home.go b/routers/user/home.go
index adf47d289c..0c7dfec7f5 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -499,19 +499,20 @@ func showOrgProfile(ctx *context.Context) {
count int64
err error
)
- repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
- Keyword: keyword,
- OwnerID: org.ID,
- OrderBy: orderBy,
- Private: ctx.IsSigned,
- UserIsAdmin: ctx.IsUserSiteAdmin(),
- UserID: ctx.Data["SignedUserID"].(int64),
- Page: page,
- IsProfile: true,
- PageSize: setting.UI.User.RepoPagingNum,
+ repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
+ Keyword: keyword,
+ OwnerID: org.ID,
+ OrderBy: orderBy,
+ Private: ctx.IsSigned,
+ UserIsAdmin: ctx.IsUserSiteAdmin(),
+ UserID: ctx.Data["SignedUserID"].(int64),
+ Page: page,
+ IsProfile: true,
+ PageSize: setting.UI.User.RepoPagingNum,
+ IncludeDescription: setting.UI.SearchRepoDescription,
})
if err != nil {
- ctx.ServerError("SearchRepositoryByName", err)
+ ctx.ServerError("SearchRepository", err)
return
}
diff --git a/routers/user/profile.go b/routers/user/profile.go
index 7df92d44f5..8a62ddeac0 100644
--- a/routers/user/profile.go
+++ b/routers/user/profile.go
@@ -169,40 +169,42 @@ func Profile(ctx *context.Context) {
}
case "stars":
ctx.Data["PageIsProfileStarList"] = true
- repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
- Keyword: keyword,
- OrderBy: orderBy,
- Private: ctx.IsSigned,
- UserIsAdmin: ctx.IsUserSiteAdmin(),
- UserID: ctx.Data["SignedUserID"].(int64),
- Page: page,
- PageSize: setting.UI.User.RepoPagingNum,
- StarredByID: ctxUser.ID,
- Collaborate: util.OptionalBoolFalse,
- TopicOnly: topicOnly,
+ repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
+ Keyword: keyword,
+ OrderBy: orderBy,
+ Private: ctx.IsSigned,
+ UserIsAdmin: ctx.IsUserSiteAdmin(),
+ UserID: ctx.Data["SignedUserID"].(int64),
+ Page: page,
+ PageSize: setting.UI.User.RepoPagingNum,
+ StarredByID: ctxUser.ID,
+ Collaborate: util.OptionalBoolFalse,
+ TopicOnly: topicOnly,
+ IncludeDescription: setting.UI.SearchRepoDescription,
})
if err != nil {
- ctx.ServerError("SearchRepositoryByName", err)
+ ctx.ServerError("SearchRepository", err)
return
}
total = int(count)
default:
- repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
- Keyword: keyword,
- OwnerID: ctxUser.ID,
- OrderBy: orderBy,
- Private: ctx.IsSigned,
- UserIsAdmin: ctx.IsUserSiteAdmin(),
- UserID: ctx.Data["SignedUserID"].(int64),
- Page: page,
- IsProfile: true,
- PageSize: setting.UI.User.RepoPagingNum,
- Collaborate: util.OptionalBoolFalse,
- TopicOnly: topicOnly,
+ repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
+ Keyword: keyword,
+ OwnerID: ctxUser.ID,
+ OrderBy: orderBy,
+ Private: ctx.IsSigned,
+ UserIsAdmin: ctx.IsUserSiteAdmin(),
+ UserID: ctx.Data["SignedUserID"].(int64),
+ Page: page,
+ IsProfile: true,
+ PageSize: setting.UI.User.RepoPagingNum,
+ Collaborate: util.OptionalBoolFalse,
+ TopicOnly: topicOnly,
+ IncludeDescription: setting.UI.SearchRepoDescription,
})
if err != nil {
- ctx.ServerError("SearchRepositoryByName", err)
+ ctx.ServerError("SearchRepository", err)
return
}