MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / GetUsageStatisticsSummary

Function GetUsageStatisticsSummary

controller/usage_statistics.go:71–100  ·  view source on GitHub ↗

GetUsageStatisticsSummary 获取用量统计摘要

(c *gin.Context)

Source from the content-addressed store, hash-verified

69
70// GetUsageStatisticsSummary 获取用量统计摘要
71func GetUsageStatisticsSummary(c *gin.Context) {
72 // 获取查询参数
73 startDate := c.Query("start_date")
74 endDate := c.Query("end_date")
75 tokenId, _ := strconv.Atoi(c.Query("token_id"))
76 modelName := c.Query("model_name")
77
78 // 设置默认查询最近7天
79 if startDate == "" && endDate == "" {
80 now := time.Now()
81 startDate = now.AddDate(0, 0, -7).Format("2006-01-02")
82 endDate = now.Format("2006-01-02")
83 }
84
85 // 获取摘要信息
86 summary, err := model.GetUsageStatisticsSummary(startDate, endDate, tokenId, modelName)
87 if err != nil {
88 c.JSON(http.StatusOK, gin.H{
89 "success": false,
90 "message": err.Error(),
91 })
92 return
93 }
94
95 c.JSON(http.StatusOK, gin.H{
96 "success": true,
97 "message": "",
98 "data": summary,
99 })
100}
101
102// GetUserUsageStatistics 获取用户自己的用量统计数据
103func GetUserUsageStatistics(c *gin.Context) {

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.80

Tested by

no test coverage detected