You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.6 KiB
42 lines
1.6 KiB
package console
|
|
|
|
import (
|
|
"yunyan/pb"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 统计 dashboard 查询接口。数据在 console 自己的公共库(AdminDB/supabase)的 stats_global_day,
|
|
// 不需要选中应用,故走全局连接、不读 X-App-Id(在 handleWeb 中先于设备域分派)。
|
|
|
|
// getStatsSummary 返回区间内的总量(全维度 SUM 成一行),支持 app/region/product 下钻。
|
|
func (this *serverComp) getStatsSummary(c *gin.Context) {
|
|
var req statsQueryReq
|
|
_ = c.ShouldBindJSON(&req)
|
|
// 前端传的是「应用名 + 国内/海外」,统计表按部署粒度存(app_id=部署名、region=细分码),先翻译。
|
|
this.normalizeStatsReq(&req)
|
|
// 代理/运营:收敛到绑定的应用∪产品(含区域);品牌商账号再收敛到自己名下渠道商∪产品;
|
|
// 渠道商账号锁死到自己那一个渠道商。
|
|
sw, sa := this.statsScopeClause(c)
|
|
out, err := queryStatSummary(&req, sw, sa)
|
|
if err != nil {
|
|
writeErr(c, pb.ErrorCode_DBError, err.Error())
|
|
return
|
|
}
|
|
writeOK(c, out)
|
|
}
|
|
|
|
// getStatsTrend 返回区间内按日聚合的序列(升序),支持 app/region/product 下钻。
|
|
func (this *serverComp) getStatsTrend(c *gin.Context) {
|
|
var req statsQueryReq
|
|
_ = c.ShouldBindJSON(&req)
|
|
// 前端传的是「应用名 + 国内/海外」,统计表按部署粒度存(app_id=部署名、region=细分码),先翻译。
|
|
this.normalizeStatsReq(&req)
|
|
sw, sa := this.statsScopeClause(c)
|
|
rows, err := queryStatTrend(&req, sw, sa)
|
|
if err != nil {
|
|
writeErr(c, pb.ErrorCode_DBError, err.Error())
|
|
return
|
|
}
|
|
writeOK(c, rows)
|
|
}
|
|
|