Skip to content

Commit

Permalink
Merge pull request #424 from factly/admin/users
Browse files Browse the repository at this point in the history
server: preload organisations in user admin endpoint
  • Loading branch information
shreeharsha-factly authored Mar 9, 2024
2 parents 560b55b + c783409 commit f8a29b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/action/admin/user/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ func list(w http.ResponseWriter, r *http.Request) {
if len(userIDs) == 0 {
qs := "%" + searchQuery + "%"
offset, limit := paginationx.Parse(r.URL.Query())
err := model.DB.Model(&model.User{}).Where("display_name ILIKE ? OR email ILIKE ?", qs, qs).Order("created_at " + sort).Count(&res.Total).Offset(offset).Limit(limit).Find(&res.Nodes).Error
err := model.DB.Model(&model.User{}).Preload("Organisations").Where("display_name ILIKE ? OR email ILIKE ?", qs, qs).Order("created_at " + sort).Count(&res.Total).Offset(offset).Limit(limit).Find(&res.Nodes).Error
if err != nil {
loggerx.Error(err)
errorx.Render(w, errorx.Parser(errorx.DBError()))
return
}
} else {
err := model.DB.Model(&model.User{}).Where(userIDs).Find(&res.Nodes).Error
err := model.DB.Model(&model.User{}).Preload("Organisations").Where(userIDs).Find(&res.Nodes).Error
if err != nil {
loggerx.Error(err)
errorx.Render(w, errorx.Parser(errorx.DBError()))
Expand Down

0 comments on commit f8a29b6

Please sign in to comment.