From 25cb1efb1f246b3df18d16b9a1a2c19819fc3dd6 Mon Sep 17 00:00:00 2001 From: sd1998 Date: Tue, 25 Dec 2018 12:57:09 +0530 Subject: [PATCH 01/15] New API routes added --- models/user.go | 10 ++++++++++ routers/api/v1/admin/org.go | 17 +++++++++++++++++ routers/api/v1/admin/user.go | 13 +++++++++++++ routers/api/v1/api.go | 3 +++ 4 files changed, 43 insertions(+) diff --git a/models/user.go b/models/user.go index a30e0d8e5261d..8dd6865912cbf 100644 --- a/models/user.go +++ b/models/user.go @@ -1360,6 +1360,16 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { Find(&users) } +func SearchUsersAPI(opts *SearchUserOptions) (users []*User,_ int64,_ error){ + cond := opts.toConds() + count,err := x.Where(cond).Count(new(User)) + if err!=nil{ + return nil,0,fmt.Errorf("Count: %v",err) + } + users = make([]*User,0,count) + return users,count,x.Where(cond).OrderBy(opts.OrderBy.String()).Find(&users) +} + // GetStarredRepos returns the repos starred by a particular user func GetStarredRepos(userID int64, private bool) ([]*Repository, error) { sess := x.Where("star.uid=?", userID). diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 406cbb9a31f27..6d1ebd2838391 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -66,3 +66,20 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { ctx.JSON(201, convert.ToOrganization(org)) } + +func GetAllOrgs(ctx *context.APIContext){ + users,_,err := models.SearchUsersAPI(&models.SearchUserOptions{ + Type: models.UserTypeOrganization, + OrderBy: models.SearchOrderByAlphabetically, + Keyword: "", + }) + if err != nil{ + ctx.Error(500,"SearchOrganizations",err) + return + } + orgs := make([]*api.Organization,len(users)) + for i := range users{ + orgs[i] = convert.ToOrganization(users[i]) + } + ctx.JSON(200,&orgs) +} diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index cff8ae4850f0b..cea926def562f 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -291,3 +291,16 @@ func DeleteUserPublicKey(ctx *context.APIContext) { ctx.Status(204) } + +func GetAllUsers(ctx *context.APIContext){ + users,_,err := models.SearchUsersAPI(&models.SearchUserOptions{ + Type: models.UserTypeIndividual, + OrderBy: models.SearchOrderByAlphabetically, + Keyword: "", + }) + if err != nil { + ctx.Error(500,"SearchUsers",err) + return + } + ctx.JSON(200,&users) +} diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 0284e845ff846..8042019c888d9 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -667,7 +667,9 @@ func RegisterRoutes(m *macaron.Macaron) { }) m.Group("/admin", func() { + m.Get("/orgs",admin.GetAllOrgs) m.Group("/users", func() { + m.Get("",admin.GetAllUsers) m.Post("", bind(api.CreateUserOption{}), admin.CreateUser) m.Group("/:username", func() { m.Combo("").Patch(bind(api.EditUserOption{}), admin.EditUser). @@ -676,6 +678,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("", bind(api.CreateKeyOption{}), admin.CreatePublicKey) m.Delete("/:id", admin.DeleteUserPublicKey) }) + m.Get("/orgs",org.ListUserOrgs) m.Post("/orgs", bind(api.CreateOrgOption{}), admin.CreateOrg) m.Post("/repos", bind(api.CreateRepoOption{}), admin.CreateRepo) }) From 8aa3b5b15c393123c9a3d3c42e8fea8bb24137dd Mon Sep 17 00:00:00 2001 From: sd1998 Date: Tue, 25 Dec 2018 19:44:51 +0530 Subject: [PATCH 02/15] Comments added --- models/user.go | 2 ++ routers/api/v1/admin/org.go | 11 +++++++++++ routers/api/v1/admin/user.go | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/models/user.go b/models/user.go index 8dd6865912cbf..99a6108b4d22f 100644 --- a/models/user.go +++ b/models/user.go @@ -1360,6 +1360,8 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { Find(&users) } +//SearchUsersAPI takes options i.e keyword and part of user name to search +//it returns all the results found and the number of total results. func SearchUsersAPI(opts *SearchUserOptions) (users []*User,_ int64,_ error){ cond := opts.toConds() count,err := x.Where(cond).Count(new(User)) diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 6d1ebd2838391..907905dfcc760 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -67,7 +67,18 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { ctx.JSON(201, convert.ToOrganization(org)) } +//GetAllOrgs API for getting information of all the organizations func GetAllOrgs(ctx *context.APIContext){ + // swagger:operation GET /admin/orgs admin adminGetAllOrgs + // --- + // summary: List all organizations + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/OrganizationList" + // "403": + // "$ref": "#/responses/forbidden" users,_,err := models.SearchUsersAPI(&models.SearchUserOptions{ Type: models.UserTypeOrganization, OrderBy: models.SearchOrderByAlphabetically, diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index cea926def562f..bc47a343c3421 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -292,7 +292,18 @@ func DeleteUserPublicKey(ctx *context.APIContext) { ctx.Status(204) } +//GetAllUsers API for getting information of all the users func GetAllUsers(ctx *context.APIContext){ + // swagger:operation GET /admin/users admin adminGetAllUsers + // --- + // summary: List all organizations + // produces: + // - application/json + // responses: + // "200": + // "$ref": "#/responses/UserList" + // "403": + // "$ref": "#/responses/forbidden" users,_,err := models.SearchUsersAPI(&models.SearchUserOptions{ Type: models.UserTypeIndividual, OrderBy: models.SearchOrderByAlphabetically, From df83324e9af97024f4103b65a92fe1de70169f64 Mon Sep 17 00:00:00 2001 From: sd1998 Date: Tue, 25 Dec 2018 20:14:14 +0530 Subject: [PATCH 03/15] Build fix --- models/user.go | 12 ++++++------ routers/api/v1/admin/org.go | 16 ++++++++-------- routers/api/v1/admin/user.go | 10 +++++----- routers/api/v1/api.go | 6 +++--- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/models/user.go b/models/user.go index 99a6108b4d22f..7302c7632ad24 100644 --- a/models/user.go +++ b/models/user.go @@ -1362,14 +1362,14 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { //SearchUsersAPI takes options i.e keyword and part of user name to search //it returns all the results found and the number of total results. -func SearchUsersAPI(opts *SearchUserOptions) (users []*User,_ int64,_ error){ +func SearchUsersAPI(opts *SearchUserOptions) (users []*User, _ int64, _ error) { cond := opts.toConds() - count,err := x.Where(cond).Count(new(User)) - if err!=nil{ - return nil,0,fmt.Errorf("Count: %v",err) + count, err := x.Where(cond).Count(new(User)) + if err != nil { + return nil, 0, fmt.Errorf("Count: %v", err) } - users = make([]*User,0,count) - return users,count,x.Where(cond).OrderBy(opts.OrderBy.String()).Find(&users) + users = make([]*User, 0, count) + return users, count, x.Where(cond).OrderBy(opts.OrderBy.String()).Find(&users) } // GetStarredRepos returns the repos starred by a particular user diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 907905dfcc760..3c07b082aba34 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -68,7 +68,7 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) { } //GetAllOrgs API for getting information of all the organizations -func GetAllOrgs(ctx *context.APIContext){ +func GetAllOrgs(ctx *context.APIContext) { // swagger:operation GET /admin/orgs admin adminGetAllOrgs // --- // summary: List all organizations @@ -79,18 +79,18 @@ func GetAllOrgs(ctx *context.APIContext){ // "$ref": "#/responses/OrganizationList" // "403": // "$ref": "#/responses/forbidden" - users,_,err := models.SearchUsersAPI(&models.SearchUserOptions{ - Type: models.UserTypeOrganization, + users, _, err := models.SearchUsersAPI(&models.SearchUserOptions{ + Type: models.UserTypeOrganization, OrderBy: models.SearchOrderByAlphabetically, Keyword: "", }) - if err != nil{ - ctx.Error(500,"SearchOrganizations",err) + if err != nil { + ctx.Error(500, "SearchOrganizations", err) return } - orgs := make([]*api.Organization,len(users)) - for i := range users{ + orgs := make([]*api.Organization, len(users)) + for i := range users { orgs[i] = convert.ToOrganization(users[i]) } - ctx.JSON(200,&orgs) + ctx.JSON(200, &orgs) } diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index bc47a343c3421..5752867a91766 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -293,7 +293,7 @@ func DeleteUserPublicKey(ctx *context.APIContext) { } //GetAllUsers API for getting information of all the users -func GetAllUsers(ctx *context.APIContext){ +func GetAllUsers(ctx *context.APIContext) { // swagger:operation GET /admin/users admin adminGetAllUsers // --- // summary: List all organizations @@ -304,14 +304,14 @@ func GetAllUsers(ctx *context.APIContext){ // "$ref": "#/responses/UserList" // "403": // "$ref": "#/responses/forbidden" - users,_,err := models.SearchUsersAPI(&models.SearchUserOptions{ - Type: models.UserTypeIndividual, + users, _, err := models.SearchUsersAPI(&models.SearchUserOptions{ + Type: models.UserTypeIndividual, OrderBy: models.SearchOrderByAlphabetically, Keyword: "", }) if err != nil { - ctx.Error(500,"SearchUsers",err) + ctx.Error(500, "SearchUsers", err) return } - ctx.JSON(200,&users) + ctx.JSON(200, &users) } diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 8042019c888d9..7e675b58d00f4 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -667,9 +667,9 @@ func RegisterRoutes(m *macaron.Macaron) { }) m.Group("/admin", func() { - m.Get("/orgs",admin.GetAllOrgs) + m.Get("/orgs", admin.GetAllOrgs) m.Group("/users", func() { - m.Get("",admin.GetAllUsers) + m.Get("", admin.GetAllUsers) m.Post("", bind(api.CreateUserOption{}), admin.CreateUser) m.Group("/:username", func() { m.Combo("").Patch(bind(api.EditUserOption{}), admin.EditUser). @@ -678,7 +678,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("", bind(api.CreateKeyOption{}), admin.CreatePublicKey) m.Delete("/:id", admin.DeleteUserPublicKey) }) - m.Get("/orgs",org.ListUserOrgs) + m.Get("/orgs", org.ListUserOrgs) m.Post("/orgs", bind(api.CreateOrgOption{}), admin.CreateOrg) m.Post("/repos", bind(api.CreateRepoOption{}), admin.CreateRepo) }) From 6bebe6af598e95669d45cf00f21b20be35866d98 Mon Sep 17 00:00:00 2001 From: sd1998 Date: Wed, 26 Dec 2018 10:19:39 +0530 Subject: [PATCH 04/15] swagger_v1_json.tmpl without new line character --- templates/swagger/v1_json.tmpl | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index ce5382152b21a..7efe9b7beef98 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -23,7 +23,45 @@ }, "basePath": "{{AppSubUrl}}/api/v1", "paths": { + "/admin/orgs": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "List all organizations", + "operationId": "adminGetAllOrgs", + "responses": { + "200": { + "$ref": "#/responses/OrganizationList" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + } + }, "/admin/users": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "List all organizations", + "operationId": "adminGetAllUsers", + "responses": { + "200": { + "$ref": "#/responses/UserList" + }, + "403": { + "$ref": "#/responses/forbidden" + } + } + }, "post": { "consumes": [ "application/json" From cce73b8d532d2f96728b5f40e1518b91d2b8aaac Mon Sep 17 00:00:00 2001 From: sd1998 Date: Wed, 26 Dec 2018 10:34:29 +0530 Subject: [PATCH 05/15] Typo fix --- routers/api/v1/admin/user.go | 2 +- templates/swagger/v1_json.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 5752867a91766..934604ff598f5 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -296,7 +296,7 @@ func DeleteUserPublicKey(ctx *context.APIContext) { func GetAllUsers(ctx *context.APIContext) { // swagger:operation GET /admin/users admin adminGetAllUsers // --- - // summary: List all organizations + // summary: List all users // produces: // - application/json // responses: diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 7efe9b7beef98..4757b785a0742 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -51,7 +51,7 @@ "tags": [ "admin" ], - "summary": "List all organizations", + "summary": "List all users", "operationId": "adminGetAllUsers", "responses": { "200": { From fd0016d9dde00c35ba5d2f47c32d8dd058b77066 Mon Sep 17 00:00:00 2001 From: sd1998 Date: Sat, 29 Dec 2018 11:39:56 +0530 Subject: [PATCH 06/15] Code review changes --- models/user.go | 4 ++-- routers/api/v1/admin/org.go | 1 - routers/api/v1/admin/user.go | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/models/user.go b/models/user.go index 7302c7632ad24..345a0fd97f598 100644 --- a/models/user.go +++ b/models/user.go @@ -1362,13 +1362,13 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { //SearchUsersAPI takes options i.e keyword and part of user name to search //it returns all the results found and the number of total results. -func SearchUsersAPI(opts *SearchUserOptions) (users []*User, _ int64, _ error) { +func SearchUsersAPI(opts *SearchUserOptions) (_ []*User, _ int64, _ error) { cond := opts.toConds() count, err := x.Where(cond).Count(new(User)) if err != nil { return nil, 0, fmt.Errorf("Count: %v", err) } - users = make([]*User, 0, count) + users := make([]*User, 0, count) return users, count, x.Where(cond).OrderBy(opts.OrderBy.String()).Find(&users) } diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 3c07b082aba34..bd93e7bd20f94 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -82,7 +82,6 @@ func GetAllOrgs(ctx *context.APIContext) { users, _, err := models.SearchUsersAPI(&models.SearchUserOptions{ Type: models.UserTypeOrganization, OrderBy: models.SearchOrderByAlphabetically, - Keyword: "", }) if err != nil { ctx.Error(500, "SearchOrganizations", err) diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 934604ff598f5..d5993d3df420f 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -307,7 +307,6 @@ func GetAllUsers(ctx *context.APIContext) { users, _, err := models.SearchUsersAPI(&models.SearchUserOptions{ Type: models.UserTypeIndividual, OrderBy: models.SearchOrderByAlphabetically, - Keyword: "", }) if err != nil { ctx.Error(500, "SearchUsers", err) From 624a9bec350304773165c203793fc621942e934f Mon Sep 17 00:00:00 2001 From: sd1998 Date: Sat, 29 Dec 2018 18:19:34 +0530 Subject: [PATCH 07/15] Code review changes --- models/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user.go b/models/user.go index 345a0fd97f598..a4381a321fc2f 100644 --- a/models/user.go +++ b/models/user.go @@ -1362,7 +1362,7 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { //SearchUsersAPI takes options i.e keyword and part of user name to search //it returns all the results found and the number of total results. -func SearchUsersAPI(opts *SearchUserOptions) (_ []*User, _ int64, _ error) { +func SearchUsersAPI(opts *SearchUserOptions) ([]*User, int64, error) { cond := opts.toConds() count, err := x.Where(cond).Count(new(User)) if err != nil { From 118a81d4645c2ff2b00e1f6247d0e5485c0ae2ea Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 23 Jan 2019 14:04:07 -0500 Subject: [PATCH 08/15] Add copyright --- models/user.go | 1 + 1 file changed, 1 insertion(+) diff --git a/models/user.go b/models/user.go index a4381a321fc2f..c1e50a08420d1 100644 --- a/models/user.go +++ b/models/user.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. From 52e579b80e9fe96c6b15f3b133e1ae62073bd92f Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 23 Jan 2019 14:04:41 -0500 Subject: [PATCH 09/15] Add copyright --- routers/api/v1/admin/org.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index bd93e7bd20f94..40e02269af82f 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -1,4 +1,5 @@ // Copyright 2015 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. From 2aa98b7967db1849a9c6a3dc7bcbe7ebc05fe3e2 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 23 Jan 2019 14:04:59 -0500 Subject: [PATCH 10/15] Add copyright --- routers/api/v1/admin/user.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index d5993d3df420f..12ed59e6e1b39 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -1,4 +1,5 @@ // Copyright 2015 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. From 20f229abce0983a1cc3c76b888f72d2f5ad9ad7c Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 23 Jan 2019 16:50:56 -0500 Subject: [PATCH 11/15] Update per @lafriks feedback --- models/user.go | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/models/user.go b/models/user.go index 9b879f8241208..2ee1537b26e99 100644 --- a/models/user.go +++ b/models/user.go @@ -1359,7 +1359,7 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { return nil, 0, fmt.Errorf("Count: %v", err) } - if opts.PageSize <= 0 || opts.PageSize > setting.UI.ExplorePagingNum { + if opts.PageSize == 0 || opts.PageSize > setting.UI.ExplorePagingNum { opts.PageSize = setting.UI.ExplorePagingNum } if opts.Page <= 0 { @@ -1369,23 +1369,13 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { opts.OrderBy = SearchOrderByAlphabetically } - users = make([]*User, 0, opts.PageSize) - return users, count, x.Where(cond). - Limit(opts.PageSize, (opts.Page-1)*opts.PageSize). - OrderBy(opts.OrderBy.String()). - Find(&users) -} - -//SearchUsersAPI takes options i.e keyword and part of user name to search -//it returns all the results found and the number of total results. -func SearchUsersAPI(opts *SearchUserOptions) ([]*User, int64, error) { - cond := opts.toConds() - count, err := x.Where(cond).Count(new(User)) - if err != nil { - return nil, 0, fmt.Errorf("Count: %v", err) + sess := x.Where(cond) + if opts.PageSize > 0 { + sess = sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize) } - users := make([]*User, 0, count) - return users, count, x.Where(cond).OrderBy(opts.OrderBy.String()).Find(&users) + + users = make([]*User, 0, opts.PageSize) + return users, count, sess.Where(cond).OrderBy(opts.OrderBy.String()).Find(&users) } // GetStarredRepos returns the repos starred by a particular user From ceec68a043daa0931dc9163305846fafa77cb68f Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 23 Jan 2019 16:51:49 -0500 Subject: [PATCH 12/15] Update org.go --- routers/api/v1/admin/org.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 40e02269af82f..3bb1df8748082 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -80,9 +80,10 @@ func GetAllOrgs(ctx *context.APIContext) { // "$ref": "#/responses/OrganizationList" // "403": // "$ref": "#/responses/forbidden" - users, _, err := models.SearchUsersAPI(&models.SearchUserOptions{ + users, _, err := models.SearchUsers(&models.SearchUserOptions{ Type: models.UserTypeOrganization, OrderBy: models.SearchOrderByAlphabetically, + PageSize: -1, }) if err != nil { ctx.Error(500, "SearchOrganizations", err) From 0b2c66eb4611f84e4cf14881f767653b39ac5188 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 23 Jan 2019 16:53:06 -0500 Subject: [PATCH 13/15] Update user.go --- routers/api/v1/admin/user.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 12ed59e6e1b39..e35beffc92e8a 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -305,9 +305,10 @@ func GetAllUsers(ctx *context.APIContext) { // "$ref": "#/responses/UserList" // "403": // "$ref": "#/responses/forbidden" - users, _, err := models.SearchUsersAPI(&models.SearchUserOptions{ - Type: models.UserTypeIndividual, - OrderBy: models.SearchOrderByAlphabetically, + users, _, err := models.SearchUsers(&models.SearchUserOptions{ + Type: models.UserTypeIndividual, + OrderBy: models.SearchOrderByAlphabetically, + PageSize: -1, }) if err != nil { ctx.Error(500, "SearchUsers", err) From 53552026700120807e9906689b303cc1431e27c8 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 23 Jan 2019 16:55:37 -0500 Subject: [PATCH 14/15] Update user.go --- models/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user.go b/models/user.go index 2ee1537b26e99..0d8f60886137a 100644 --- a/models/user.go +++ b/models/user.go @@ -1375,7 +1375,7 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { } users = make([]*User, 0, opts.PageSize) - return users, count, sess.Where(cond).OrderBy(opts.OrderBy.String()).Find(&users) + return users, count, sess.OrderBy(opts.OrderBy.String()).Find(&users) } // GetStarredRepos returns the repos starred by a particular user From 5408007befcffca14b6d8211cdc0f96666d17481 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 23 Jan 2019 16:59:56 -0500 Subject: [PATCH 15/15] make fmt --- routers/api/v1/admin/org.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 3bb1df8748082..03263a86dd9ef 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -81,8 +81,8 @@ func GetAllOrgs(ctx *context.APIContext) { // "403": // "$ref": "#/responses/forbidden" users, _, err := models.SearchUsers(&models.SearchUserOptions{ - Type: models.UserTypeOrganization, - OrderBy: models.SearchOrderByAlphabetically, + Type: models.UserTypeOrganization, + OrderBy: models.SearchOrderByAlphabetically, PageSize: -1, }) if err != nil {