mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
swag: add new statistics tag, add filtered user count route
This commit is contained in:
36
api-users.go
36
api-users.go
@@ -911,7 +911,7 @@ func (app *appContext) userSummary(jfUser mediabrowser.User) respUser {
|
||||
// @Success 200 {object} PageCountDTO
|
||||
// @Router /users/count [get]
|
||||
// @Security Bearer
|
||||
// @tags Activity
|
||||
// @tags Activity,Statistics
|
||||
func (app *appContext) GetUserCount(gc *gin.Context) {
|
||||
resp := PageCountDTO{}
|
||||
users, err := app.jf.GetUsers(false)
|
||||
@@ -952,7 +952,7 @@ func (app *appContext) GetUsers(gc *gin.Context) {
|
||||
// @Failure 500 {object} stringResponse
|
||||
// @Router /users [post]
|
||||
// @Security Bearer
|
||||
// @tags Users
|
||||
// @tags Users,Statistics
|
||||
func (app *appContext) SearchUsers(gc *gin.Context) {
|
||||
req := ServerSearchReqDTO{}
|
||||
gc.BindJSON(&req)
|
||||
@@ -991,6 +991,38 @@ func (app *appContext) SearchUsers(gc *gin.Context) {
|
||||
gc.JSON(200, resp)
|
||||
}
|
||||
|
||||
// @Summary Get a count of users matching the search provided
|
||||
// @Produce json
|
||||
// @Param ServerSearchReqDTO body ServerSearchReqDTO true "search / pagination parameters"
|
||||
// @Success 200 {object} PageCountDTO
|
||||
// @Failure 500 {object} stringResponse
|
||||
// @Router /users/count [post]
|
||||
// @Security Bearer
|
||||
// @tags Users,Statistics
|
||||
func (app *appContext) GetFilteredUserCount(gc *gin.Context) {
|
||||
req := ServerSearchReqDTO{}
|
||||
gc.BindJSON(&req)
|
||||
if req.SortByField == "" {
|
||||
req.SortByField = USER_DEFAULT_SORT_FIELD
|
||||
}
|
||||
|
||||
var resp PageCountDTO
|
||||
// No need to sort
|
||||
userList, err := app.userCache.GetUserDTOs(app, false)
|
||||
if err != nil {
|
||||
app.err.Printf(lm.FailedGetUsers, lm.Jellyfin, err)
|
||||
respond(500, "Couldn't get users", gc)
|
||||
return
|
||||
}
|
||||
if len(req.SearchTerms) != 0 || len(req.Queries) != 0 {
|
||||
resp.Count = uint64(len(app.userCache.Filter(userList, req.SearchTerms, req.Queries)))
|
||||
} else {
|
||||
resp.Count = uint64(len(userList))
|
||||
}
|
||||
|
||||
gc.JSON(200, resp)
|
||||
}
|
||||
|
||||
// @Summary Set whether or not a user can access jfa-go. Redundant if the user is a Jellyfin admin.
|
||||
// @Produce json
|
||||
// @Param setAccountsAdminDTO body setAccountsAdminDTO true "Map of userIDs to whether or not they have access."
|
||||
|
||||
Reference in New Issue
Block a user