diff --git a/soul-api/internal/handler/match_records.go b/soul-api/internal/handler/match_records.go index 389e3e6b..098dfd00 100644 --- a/soul-api/internal/handler/match_records.go +++ b/soul-api/internal/handler/match_records.go @@ -21,11 +21,11 @@ func DBMatchRecordsList(c *gin.Context) { var todayMatches int64 db.Model(&model.MatchRecord{}).Where("created_at >= CURDATE()").Count(&todayMatches) type TypeCount struct { - MatchType string `json:"matchType"` - Count int64 `json:"count"` + MatchType string `json:"matchType" gorm:"column:match_type"` + Count int64 `json:"count" gorm:"column:count"` } var byType []TypeCount - db.Model(&model.MatchRecord{}).Select("match_type as match_type, count(*) as count").Group("match_type").Scan(&byType) + db.Raw("SELECT match_type, COUNT(*) as count FROM match_records GROUP BY match_type").Scan(&byType) var uniqueUsers int64 db.Raw("SELECT COUNT(DISTINCT user_id) FROM match_records WHERE user_id IS NOT NULL AND user_id != ''").Scan(&uniqueUsers)