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 { RecentJoinPlayerReq {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // 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 { RecentJoinPlayerResp {
Players []RecentJoinPlayerRespPlayer `json:"players"` // List of player SteamID64s who joined in the time range Players []RecentJoinPlayerRespPlayer `json:"players"` // List of player SteamID64s who joined in the time range
@@ -111,6 +112,7 @@ type (
RecentChatMessageReq { RecentChatMessageReq {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // 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 { RecentChatMessageResp {
Messages []RecentChatMessageRespMessage `json:"messages"` // List of recent chat messages Messages []RecentChatMessageRespMessage `json:"messages"` // List of recent chat messages
@@ -132,6 +134,7 @@ type (
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
LeastPlayTime int64 `json:"leastPlayTime"` // Least playtime in seconds to filter by 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 { RecentPlayResp {
Players []RecentPlayRespPlayer `json:"players"` // List of players who played in the time range Players []RecentPlayRespPlayer `json:"players"` // List of players who played in the time range
@@ -148,6 +151,7 @@ type (
TopPlayTimeReq { TopPlayTimeReq {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // 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 { TopPlayTimeResp {
Players []TopPlayTimeRespPlayer `json:"players"` // List of top players by playtime Players []TopPlayTimeRespPlayer `json:"players"` // List of top players by playtime
@@ -163,6 +167,7 @@ type (
TopKillerReq { TopKillerReq {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // 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 { TopKillerResp {
Players []TopKillerRespPlayer `json:"players"` // List of top players by kill count 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) WHERE message_time >= TO_TIMESTAMP($1 / 1000.0)
AND message_time <= TO_TIMESTAMP($2 / 1000.0) AND message_time <= TO_TIMESTAMP($2 / 1000.0)
ORDER BY message_time DESC 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 { if err != nil {
l.Errorf("Failed to query recent chat messages: %v", err) l.Errorf("Failed to query recent chat messages: %v", err)
return nil, 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.log_time <= TO_TIMESTAMP($2 / 1000.0)
AND c.steamid64 > 1 AND c.steamid64 > 1
ORDER BY c.log_time DESC 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 { if err != nil {
l.Errorf("Failed to query recent join players: %v", err) l.Errorf("Failed to query recent join players: %v", err)
return nil, err return nil, err

View File

@@ -34,9 +34,10 @@ func (l *RecentPlayLogic) RecentPlay(req *types.RecentPlayReq) (resp *types.Rece
AND duration >= $3 AND duration >= $3
AND steamid64 > 1 AND steamid64 > 1
ORDER BY duration DESC 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 { if err != nil {
l.Errorf("Failed to query recent play: %v", err) l.Errorf("Failed to query recent play: %v", err)
return nil, err return nil, err

View File

@@ -34,10 +34,10 @@ func (l *TopKillerLogic) TopKiller(req *types.TopKillerReq) (resp *types.TopKill
AND attacker_steamid64 > 1 AND attacker_steamid64 > 1
GROUP BY attacker_steamid64, attacker_name GROUP BY attacker_steamid64, attacker_name
ORDER BY kill_count DESC 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 { if err != nil {
l.Errorf("Failed to query top killers: %v", err) l.Errorf("Failed to query top killers: %v", err)
return nil, err return nil, err

View File

@@ -35,10 +35,10 @@ func (l *TopPlayTimeLogic) TopPlayTime(req *types.TopPlayTimeReq) (resp *types.T
AND c.steamid64 > 1 AND c.steamid64 > 1
GROUP BY c.steamid64, c.player_name GROUP BY c.steamid64, c.player_name
ORDER BY total_playtime DESC 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 { if err != nil {
l.Errorf("Failed to query top playtime: %v", err) l.Errorf("Failed to query top playtime: %v", err)
return nil, err return nil, err

View File

@@ -11,8 +11,9 @@ type PingResp struct {
} }
type RecentChatMessageReq struct { type RecentChatMessageReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // 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 { type RecentChatMessageResp struct {
@@ -31,8 +32,9 @@ type RecentChatMessageRespMessage struct {
} }
type RecentJoinPlayerReq struct { type RecentJoinPlayerReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // 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 { type RecentJoinPlayerResp struct {
@@ -47,9 +49,10 @@ type RecentJoinPlayerRespPlayer struct {
} }
type RecentPlayReq struct { type RecentPlayReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
LeastPlayTime int64 `json:"leastPlayTime"` // Least playtime in seconds to filter by 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 { type RecentPlayResp struct {
@@ -64,8 +67,9 @@ type RecentPlayRespPlayer struct {
} }
type TopKillerReq struct { type TopKillerReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // 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 { type TopKillerResp struct {
@@ -79,8 +83,9 @@ type TopKillerRespPlayer struct {
} }
type TopPlayTimeReq struct { type TopPlayTimeReq struct {
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
TimeRangeEnd int64 `json:"timeRangeEnd"` // 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 { type TopPlayTimeResp struct {