Skip to content

Commit 20691ac

Browse files
committed
Hide users from explore view who have no repos (unless searched for)
1 parent 454ee83 commit 20691ac

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

models/user.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,7 @@ type SearchUserOptions struct {
15901590
Actor *User // The user doing the search
15911591
IsActive util.OptionalBool
15921592
SearchByEmail bool // Search by email as well as username/full name
1593+
HideNoRepos util.OptionalBool
15931594
}
15941595

15951596
func (opts *SearchUserOptions) toConds() builder.Cond {
@@ -1643,6 +1644,10 @@ func (opts *SearchUserOptions) toConds() builder.Cond {
16431644
cond = cond.And(builder.Eq{"is_active": opts.IsActive.IsTrue()})
16441645
}
16451646

1647+
if opts.HideNoRepos.IsTrue() {
1648+
cond = cond.And(builder.Expr("num_repos > 0"));
1649+
}
1650+
16461651
return cond
16471652
}
16481653

routers/home.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ func RenderUserSearch(ctx *context.Context, opts *models.SearchUserOptions, tplN
233233
}
234234

235235
opts.Keyword = strings.Trim(ctx.Query("q"), " ")
236+
237+
238+
if (opts.HideNoRepos == util.OptionalBoolTrue) && (opts.Keyword != "") {
239+
opts.HideNoRepos = util.OptionalBoolFalse;
240+
}
241+
236242
opts.OrderBy = orderBy
237243
if len(opts.Keyword) == 0 || isKeywordValid(opts.Keyword) {
238244
users, count, err = models.SearchUsers(opts)
@@ -272,6 +278,7 @@ func ExploreUsers(ctx *context.Context) {
272278
ListOptions: models.ListOptions{PageSize: setting.UI.ExplorePagingNum},
273279
IsActive: util.OptionalBoolTrue,
274280
Visible: []structs.VisibleType{structs.VisibleTypePublic, structs.VisibleTypeLimited, structs.VisibleTypePrivate},
281+
HideNoRepos: util.OptionalBoolTrue,
275282
}, tplExploreUsers)
276283
}
277284

@@ -293,6 +300,7 @@ func ExploreOrganizations(ctx *context.Context) {
293300
Type: models.UserTypeOrganization,
294301
ListOptions: models.ListOptions{PageSize: setting.UI.ExplorePagingNum},
295302
Visible: visibleTypes,
303+
HideNoRepos: util.OptionalBoolTrue,
296304
}, tplExploreOrganizations)
297305
}
298306

0 commit comments

Comments
 (0)