From 0a6487b3d023ea097d2d58557ab9c98fde1814fc Mon Sep 17 00:00:00 2001 From: Artur Galyamov Date: Fri, 2 Sep 2022 16:58:17 +0500 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4?= =?UTF-8?q?=D0=BA=D0=B5=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B5=D1=82=D0=B5=D0=BD?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D1=8F=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=B8=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D0=B0=20=D1=82=D0=BE=D0=B6=D0=B5=20#106?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/user/search.go | 12 ++++++++++-- models/user/user.go | 3 +++ routers/web/explore/competence.go | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/models/user/search.go b/models/user/search.go index 24a21777e8..453d09558d 100644 --- a/models/user/search.go +++ b/models/user/search.go @@ -39,13 +39,21 @@ type SearchUserOptions struct { } func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session { - var cond builder.Cond = builder.Eq{"type": opts.Type} + var cond builder.Cond + if opts.Type == UserTypeIdentity { + cond = builder.Or( + builder.Eq{"type": UserTypeIndividual}, + builder.Eq{"type": UserTypeOrganization}, + ) + } else { + cond = builder.Eq{"type": opts.Type} + } if len(opts.Keyword) > 0 { lowerKeyword := strings.ToLower(opts.Keyword) keywordCond := builder.Or( builder.Like{"lower_name", lowerKeyword}, builder.Like{"LOWER(full_name)", lowerKeyword}, - builder.Like{"LOWER(description)", lowerKeyword}, + builder.Like{"LOWER(description)", lowerKeyword}, ) if opts.SearchByEmail { keywordCond = keywordCond.Or(builder.Like{"LOWER(email)", lowerKeyword}) diff --git a/models/user/user.go b/models/user/user.go index 5ce5d3cbd5..9270951449 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -46,6 +46,9 @@ const ( // UserTypeOrganization defines an organization UserTypeOrganization + + // UserTypeIdentity defines individual + organization + UserTypeIdentity ) const ( diff --git a/routers/web/explore/competence.go b/routers/web/explore/competence.go index 0fb9d90067..ccd7bf64f2 100644 --- a/routers/web/explore/competence.go +++ b/routers/web/explore/competence.go @@ -23,7 +23,7 @@ func Competences(ctx *context.Context) { RenderUserSearch(ctx, &user_model.SearchUserOptions{ Actor: ctx.User, - Type: user_model.UserTypeIndividual, + Type: user_model.UserTypeIdentity, ListOptions: db.ListOptions{PageSize: setting.UI.ExplorePagingNum}, IsActive: util.OptionalBoolTrue, Visible: []structs.VisibleType{structs.VisibleTypePublic, structs.VisibleTypeLimited, structs.VisibleTypePrivate},