Skip to content

Commit

Permalink
solves #173
Browse files Browse the repository at this point in the history
  • Loading branch information
deinelieblings committed Jun 21, 2024
1 parent e13f83c commit 96237ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions dao/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ func UserInsert(ctx context.Context, i *models.UserDatabase) (result *models.Use
return
}

func UsersGet(ctx context.Context, i *models.UserQuery, token *vcapool.AccessToken) (result *[]models.ListUser, list_size int64, err error) {
func UsersGet(i *models.UserQuery, token *vcapool.AccessToken) (result *[]models.ListUser, list_size int64, err error) {
if err = models.UsersPermission(token); err != nil {
return
}
ctx = context.Background()
ctx := context.Background()
filter := i.PermittedFilter(token)
sort := i.Sort()
opt := options.Aggregate()
opt.SetCollation(&options.Collation{Locale: "en_US", NumericOrdering: true})

pipeline := models.SortedUserPermittedPipeline(token).SortFields(sort).Match(filter).Sort(sort).Skip(i.Skip, 0).Limit(i.Limit, 100).Pipe
result = new([]models.ListUser)
if err = UserCollection.Aggregate(ctx, pipeline, result); err != nil {
if err = UserCollection.Aggregate(ctx, pipeline, result, opt); err != nil {
return
}
opts := options.Count().SetHint("_id_")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module pool-backend
go 1.17

require (
github.com/Viva-con-Agua/vcago v1.4.42
github.com/Viva-con-Agua/vcago v1.5.5
github.com/Viva-con-Agua/vcapool v0.3.4
github.com/google/uuid v1.3.0
github.com/labstack/echo/v4 v4.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Viva-con-Agua/vcago v1.4.16/go.mod h1:kxaxW9VYWIaCdWoM+PLHNwXmtPj4FPYHPxmPK6JsA1U=
github.com/Viva-con-Agua/vcago v1.4.42 h1:+UxsScecaZqEYTNbrUPHxc4Rn/wFJEayxDAjcJjnphU=
github.com/Viva-con-Agua/vcago v1.4.42/go.mod h1:uJ7sBZk8IOEJbHgZ97uY+WE6TLMGkhiPvey3CxFOs4A=
github.com/Viva-con-Agua/vcago v1.5.5 h1:bnxyyVpuLoLHwmWOdJEqwF+3x4PEek3do8j0BSUFQ9I=
github.com/Viva-con-Agua/vcago v1.5.5/go.mod h1:uJ7sBZk8IOEJbHgZ97uY+WE6TLMGkhiPvey3CxFOs4A=
github.com/Viva-con-Agua/vcapool v0.3.4 h1:I1IGg7BTfXihMkTwLu+qYygcvfX9zZVMZw9+0B9ZJMs=
github.com/Viva-con-Agua/vcapool v0.3.4/go.mod h1:yTwmyj5DbsDduM23aEbK48BW0ONg9092hbmm1HhMso4=
github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249/go.mod h1:iU1PxQMQwoHZZWmMKrMkrNlY+3+p9vxIjpZOVyxWa0g=
Expand Down
2 changes: 1 addition & 1 deletion handlers/token/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (i *UserHandler) Get(cc echo.Context) (err error) {
}
result := new([]models.ListUser)
var listSize int64
if result, listSize, err = dao.UsersGet(c.Ctx(), body, token); err != nil {
if result, listSize, err = dao.UsersGet(body, token); err != nil {
return
}
return c.Listed(result, listSize)
Expand Down

0 comments on commit 96237ca

Please sign in to comment.