diff options
author | Lauris BH <lauris@nix.lv> | 2022-01-28 13:29:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 13:29:04 +0200 |
commit | 604ce776287545b31991f0c78b13854b36ed2f59 (patch) | |
tree | 6a3cb4ce33d8b4044548c0841730884384b41881 /models | |
parent | 401e5c817474436218af08602da5135774d2c0eb (diff) | |
download | gitea-604ce776287545b31991f0c78b13854b36ed2f59.tar.gz gitea-604ce776287545b31991f0c78b13854b36ed2f59.zip |
Allow to filter repositories by language in explore, user and organization repositories lists (#18430)
Diffstat (limited to 'models')
-rw-r--r-- | models/repo_list.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/models/repo_list.go b/models/repo_list.go index 290919bb6d..36f57abcc5 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -136,6 +136,8 @@ type SearchRepoOptions struct { Archived util.OptionalBool // only search topic name TopicOnly bool + // only search repositories with specified primary language + Language string // include description in keyword search IncludeDescription bool // None -> include has milestones AND has no milestone @@ -439,6 +441,13 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { cond = cond.And(keywordCond) } + if opts.Language != "" { + cond = cond.And(builder.In("id", builder. + Select("repo_id"). + From("language_stat"). + Where(builder.Eq{"language": opts.Language}).And(builder.Eq{"is_primary": true}))) + } + if opts.Fork != util.OptionalBoolNone { cond = cond.And(builder.Eq{"is_fork": opts.Fork == util.OptionalBoolTrue}) } |