All checks were successful
Server Check Build (NixCN CMS) TeamCity build finished
Signed-off-by: Asai Neko <sugar@sne.moe>
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package stats
|
|
|
|
import (
|
|
"nixcn-cms/internal/exception"
|
|
"nixcn-cms/service/service_stats"
|
|
"nixcn-cms/tracer"
|
|
"nixcn-cms/utils"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// Global returns platform-wide statistics. Lv40+ only.
|
|
//
|
|
// @Summary Global Stats
|
|
// @Description Returns total users, user counts per permission_level, and per-event join/checkin counts.
|
|
// @Tags Stats
|
|
// @Produce json
|
|
// @Security Bearer
|
|
// @Success 200 {object} utils.RespStatus{data=service_stats.GlobalStatsResponse}
|
|
// @Failure 401 {object} utils.RespStatus{data=nil} "Unauthorized"
|
|
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
|
|
// @Router /stats/global [get]
|
|
func (self *StatsHandler) Global(c *gin.Context) {
|
|
ctx, span := tracer.StartSpan(
|
|
c.Request.Context(),
|
|
"api_stats",
|
|
"global",
|
|
)
|
|
defer span.End()
|
|
|
|
ctx = exception.ContextWithEndpoint(ctx, exception.EndpointStatsGlobal)
|
|
ctx = exception.ContextWithService(ctx, exception.ServiceEndpoint)
|
|
|
|
result := self.svc.Global(&service_stats.GlobalStatsPayload{
|
|
Context: ctx,
|
|
})
|
|
|
|
if result.Common.Exception.Original != exception.CommonSuccess {
|
|
utils.HttpResponse(c, result.Common.HttpCode, result.Common.Exception.String())
|
|
return
|
|
}
|
|
|
|
utils.HttpResponse(c, result.Common.HttpCode, result.Common.Exception.String(), result.Data)
|
|
}
|