Skip to content

Commit 4d20a4a

Browse files
delvhzeripathlunny
authored
Remove ONLY_SHOW_RELEVANT_REPOS setting (#21962)
Every user can already disable the filter manually, so the explicit setting is absolutely useless and only complicates the logic. Previously, there was also unexpected behavior when multiple query parameters were present. --------- Co-authored-by: zeripath <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent ea13b23 commit 4d20a4a

File tree

5 files changed

+9
-18
lines changed

5 files changed

+9
-18
lines changed

custom/conf/app.example.ini

-4
Original file line numberDiff line numberDiff line change
@@ -1222,10 +1222,6 @@ ROUTER = console
12221222
;;
12231223
;; Whether to enable a Service Worker to cache frontend assets
12241224
;USE_SERVICE_WORKER = false
1225-
;;
1226-
;; Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
1227-
;; A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
1228-
;ONLY_SHOW_RELEVANT_REPOS = false
12291225

12301226
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12311227
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ The following configuration set `Content-Type: application/vnd.android.package-a
231231
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
232232
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
233233
- `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets.
234-
- `ONLY_SHOW_RELEVANT_REPOS`: **false** Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
235-
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
236234

237235
### UI - Admin (`ui.admin`)
238236

models/repo/repo_list.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
494494
}
495495

496496
if opts.OnlyShowRelevant {
497-
// Only show a repo that either has a topic or description.
497+
// Only show a repo that has at least a topic, an icon, or a description
498498
subQueryCond := builder.NewCond()
499499

500500
// Topic checking. Topics are present.
@@ -504,13 +504,13 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
504504
subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"}))
505505
}
506506

507-
// Description checking. Description not empty.
507+
// Description checking. Description not empty
508508
subQueryCond = subQueryCond.Or(builder.Neq{"description": ""})
509509

510-
// Repo has a avatar.
510+
// Repo has a avatar
511511
subQueryCond = subQueryCond.Or(builder.Neq{"avatar": ""})
512512

513-
// Always hide repo's that are empty.
513+
// Always hide repo's that are empty
514514
subQueryCond = subQueryCond.And(builder.Eq{"is_empty": false})
515515

516516
cond = cond.And(subQueryCond)

modules/setting/setting.go

-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ var (
241241
CustomEmojisMap map[string]string `ini:"-"`
242242
SearchRepoDescription bool
243243
UseServiceWorker bool
244-
OnlyShowRelevantRepos bool
245244

246245
Notification struct {
247246
MinTimeout time.Duration
@@ -1123,7 +1122,6 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
11231122
UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false)
11241123
UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true)
11251124
UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false)
1126-
UI.OnlyShowRelevantRepos = Cfg.Section("ui").Key("ONLY_SHOW_RELEVANT_REPOS").MustBool(false)
11271125

11281126
HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt"))
11291127
if err != nil {

routers/web/explore/repo.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import (
1717

1818
const (
1919
// tplExploreRepos explore repositories page template
20-
tplExploreRepos base.TplName = "explore/repos"
20+
tplExploreRepos base.TplName = "explore/repos"
21+
relevantReposOnlyParam string = "no_filter"
2122
)
2223

2324
// RepoSearchOptions when calling search repositories
@@ -81,13 +82,11 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
8182
default:
8283
ctx.Data["SortType"] = "recentupdate"
8384
orderBy = db.SearchOrderByRecentUpdated
84-
onlyShowRelevant = setting.UI.OnlyShowRelevantRepos && !ctx.FormBool("no_filter")
8585
}
8686

87+
onlyShowRelevant = !ctx.FormBool(relevantReposOnlyParam)
88+
8789
keyword := ctx.FormTrim("q")
88-
if keyword != "" {
89-
onlyShowRelevant = false
90-
}
9190

9291
ctx.Data["OnlyShowRelevant"] = onlyShowRelevant
9392

@@ -139,7 +138,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
139138
pager.SetDefaultParams(ctx)
140139
pager.AddParam(ctx, "topic", "TopicOnly")
141140
pager.AddParam(ctx, "language", "Language")
142-
pager.AddParamString("no_filter", ctx.FormString("no_filter"))
141+
pager.AddParamString(relevantReposOnlyParam, ctx.FormString(relevantReposOnlyParam))
143142
ctx.Data["Page"] = pager
144143

145144
ctx.HTML(http.StatusOK, opts.TplName)

0 commit comments

Comments
 (0)