chore: 停止上传开发文档并同步代码

- 从仓库索引移除 开发文档/(本地保留)
- 忽略 wechat/info.log 与 soul-api-linux
- 同步小程序/管理端/API改动

Made-with: Cursor
This commit is contained in:
卡若
2026-03-17 15:25:26 +08:00
parent c6904e4a32
commit f9d5e85b4e
350 changed files with 2588 additions and 64437 deletions

View File

@@ -11,7 +11,6 @@ import (
)
// AdminTrackStats GET /api/admin/track/stats 管理端-按钮/标签点击统计(按模块+action聚合
// 查询参数period=today|week|month|all默认 today
func AdminTrackStats(c *gin.Context) {
period := c.DefaultQuery("period", "today")
db := database.DB()
@@ -29,25 +28,26 @@ func AdminTrackStats(c *gin.Context) {
since = time.Time{}
}
type trackRow struct {
type rawRow struct {
Action string `gorm:"column:action"`
Target string `gorm:"column:target"`
ExtraData []byte `gorm:"column:extra_data"`
Count int64 `gorm:"column:count"`
}
query := db.Table("user_tracks").
Select("action, COALESCE(target, '') as target, extra_data, COUNT(*) as count").
Group("action, COALESCE(target, ''), extra_data").
Order("count DESC")
query := db.Table("user_tracks").Select("action, COALESCE(target, '') as target, extra_data")
if !since.IsZero() {
query = query.Where("created_at >= ?", since)
}
query = query.Where("action NOT LIKE '%union%' AND action NOT LIKE '%jndi%' AND action NOT LIKE '%SLEEP%'")
var rows []trackRow
query.Find(&rows)
var rawRows []rawRow
query.Find(&rawRows)
type statKey struct {
Module string
Action string
Target string
}
type statItem struct {
Action string `json:"action"`
Target string `json:"target"`
@@ -56,10 +56,10 @@ func AdminTrackStats(c *gin.Context) {
Count int64 `json:"count"`
}
byModule := make(map[string][]statItem)
aggregated := make(map[statKey]*statItem)
total := int64(0)
for _, r := range rows {
for _, r := range rawRows {
module := "other"
page := ""
if len(r.ExtraData) > 0 {
@@ -73,15 +73,24 @@ func AdminTrackStats(c *gin.Context) {
}
}
}
item := statItem{
Action: r.Action,
Target: r.Target,
Module: module,
Page: page,
Count: r.Count,
key := statKey{Module: module, Action: r.Action, Target: r.Target}
if existing, ok := aggregated[key]; ok {
existing.Count++
} else {
aggregated[key] = &statItem{
Action: r.Action,
Target: r.Target,
Module: module,
Page: page,
Count: 1,
}
}
byModule[module] = append(byModule[module], item)
total += r.Count
total++
}
byModule := make(map[string][]statItem)
for _, item := range aggregated {
byModule[item.Module] = append(byModule[item.Module], *item)
}
c.JSON(http.StatusOK, gin.H{