This commit is contained in:
2025-10-04 18:04:33 +08:00
parent 14936b7384
commit e0870ba147
7 changed files with 31 additions and 18 deletions

View File

@@ -33,9 +33,10 @@ func (l *RecentChatMessageLogic) RecentChatMessage(req *types.RecentChatMessageR
WHERE message_time >= TO_TIMESTAMP($1 / 1000.0)
AND message_time <= TO_TIMESTAMP($2 / 1000.0)
ORDER BY message_time DESC
LIMIT $3
`
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd)
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd, req.Limit)
if err != nil {
l.Errorf("Failed to query recent chat messages: %v", err)
return nil, err

View File

@@ -37,9 +37,10 @@ func (l *RecentJoinPlayerLogic) RecentJoinPlayer(req *types.RecentJoinPlayerReq)
AND c.log_time <= TO_TIMESTAMP($2 / 1000.0)
AND c.steamid64 > 1
ORDER BY c.log_time DESC
LIMIT $3
`
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd)
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd, req.Limit)
if err != nil {
l.Errorf("Failed to query recent join players: %v", err)
return nil, err

View File

@@ -34,9 +34,10 @@ func (l *RecentPlayLogic) RecentPlay(req *types.RecentPlayReq) (resp *types.Rece
AND duration >= $3
AND steamid64 > 1
ORDER BY duration DESC
LIMIT $4
`
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd, req.LeastPlayTime)
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd, req.LeastPlayTime, req.Limit)
if err != nil {
l.Errorf("Failed to query recent play: %v", err)
return nil, err

View File

@@ -34,10 +34,10 @@ func (l *TopKillerLogic) TopKiller(req *types.TopKillerReq) (resp *types.TopKill
AND attacker_steamid64 > 1
GROUP BY attacker_steamid64, attacker_name
ORDER BY kill_count DESC
LIMIT 100
LIMIT $3
`
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd)
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd, req.Limit)
if err != nil {
l.Errorf("Failed to query top killers: %v", err)
return nil, err

View File

@@ -35,10 +35,10 @@ func (l *TopPlayTimeLogic) TopPlayTime(req *types.TopPlayTimeReq) (resp *types.T
AND c.steamid64 > 1
GROUP BY c.steamid64, c.player_name
ORDER BY total_playtime DESC
LIMIT 100
LIMIT $3
`
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd)
rows, err := l.svcCtx.DB.QueryContext(l.ctx, query, req.TimeRangeStart, req.TimeRangeEnd, req.Limit)
if err != nil {
l.Errorf("Failed to query top playtime: %v", err)
return nil, err

View File

@@ -11,8 +11,9 @@ type PingResp struct {
}
type RecentChatMessageReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
Limit int `json:"limit,range=[1:10],example=10,default=10"` // Maximum number of messages to return
}
type RecentChatMessageResp struct {
@@ -31,8 +32,9 @@ type RecentChatMessageRespMessage struct {
}
type RecentJoinPlayerReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
Limit int `json:"limit,range=[1:10],example=10,default=10"` // Maximum number of players to return
}
type RecentJoinPlayerResp struct {
@@ -47,9 +49,10 @@ type RecentJoinPlayerRespPlayer struct {
}
type RecentPlayReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
LeastPlayTime int64 `json:"leastPlayTime"` // Least playtime in seconds to filter by
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
LeastPlayTime int64 `json:"leastPlayTime"` // Least playtime in seconds to filter by
Limit int `json:"limit,range=[1:10],example=10,default=10"` // Maximum number of players to return
}
type RecentPlayResp struct {
@@ -64,8 +67,9 @@ type RecentPlayRespPlayer struct {
}
type TopKillerReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
Limit int `json:"limit,range=[1:10],example=10,default=10"` // Maximum number of players to return
}
type TopKillerResp struct {
@@ -79,8 +83,9 @@ type TopKillerRespPlayer struct {
}
type TopPlayTimeReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
Limit int `json:"limit,range=[1:10],example=10,default=10"` // Maximum number of players to return
}
type TopPlayTimeResp struct {