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

@@ -95,6 +95,7 @@ type (
RecentJoinPlayerReq {
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
}
RecentJoinPlayerResp {
Players []RecentJoinPlayerRespPlayer `json:"players"` // List of player SteamID64s who joined in the time range
@@ -111,6 +112,7 @@ type (
RecentChatMessageReq {
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
}
RecentChatMessageResp {
Messages []RecentChatMessageRespMessage `json:"messages"` // List of recent chat messages
@@ -132,6 +134,7 @@ type (
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
}
RecentPlayResp {
Players []RecentPlayRespPlayer `json:"players"` // List of players who played in the time range
@@ -148,6 +151,7 @@ type (
TopPlayTimeReq {
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
}
TopPlayTimeResp {
Players []TopPlayTimeRespPlayer `json:"players"` // List of top players by playtime
@@ -163,6 +167,7 @@ type (
TopKillerReq {
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
}
TopKillerResp {
Players []TopKillerRespPlayer `json:"players"` // List of top players by kill count

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

@@ -13,6 +13,7 @@ type PingResp struct {
type RecentChatMessageReq struct {
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 {
@@ -33,6 +34,7 @@ type RecentChatMessageRespMessage struct {
type RecentJoinPlayerReq struct {
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 {
@@ -50,6 +52,7 @@ 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
Limit int `json:"limit,range=[1:10],example=10,default=10"` // Maximum number of players to return
}
type RecentPlayResp struct {
@@ -66,6 +69,7 @@ type RecentPlayRespPlayer struct {
type TopKillerReq struct {
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 {
@@ -81,6 +85,7 @@ type TopKillerRespPlayer struct {
type TopPlayTimeReq struct {
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 {