Get the count of the all system users at endpoint /users/stats (#8847)

* Get the count of the all system users at endpoint /users/stats

* Added GetTotalUsersStats test in api4

* Changed pluralization and added the test back.
Этот коммит содержится в:
lisakycho
2018-06-07 09:45:49 -07:00
коммит произвёл Joram Wilander
родитель c8d9595833
Коммит e09b3c566b
5 изменённых файлов: 80 добавлений и 20 удалений

Просмотреть файл

@@ -22,6 +22,7 @@ func (api *API) InitUser() {
api.BaseRoutes.Users.Handle("/usernames", api.ApiSessionRequired(getUsersByNames)).Methods("POST")
api.BaseRoutes.Users.Handle("/search", api.ApiSessionRequired(searchUsers)).Methods("POST")
api.BaseRoutes.Users.Handle("/autocomplete", api.ApiSessionRequired(autocompleteUsers)).Methods("GET")
api.BaseRoutes.Users.Handle("/stats", api.ApiSessionRequired(getTotalUsersStats)).Methods("GET")
api.BaseRoutes.User.Handle("", api.ApiSessionRequired(getUser)).Methods("GET")
api.BaseRoutes.User.Handle("/image", api.ApiSessionRequiredTrustRequester(getProfileImage)).Methods("GET")
@@ -278,6 +279,20 @@ func setProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
ReturnStatusOK(w)
}
func getTotalUsersStats(c *Context, w http.ResponseWriter, r *http.Request) {
if c.Err != nil {
return
}
if stats, err := c.App.GetTotalUsersStats(); err != nil {
c.Err = err
return
} else {
w.Write([]byte(stats.ToJson()))
return
}
}
func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
inTeamId := r.URL.Query().Get("in_team")
notInTeamId := r.URL.Query().Get("not_in_team")