feat: add total player count and total playtime logic
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 1m27s
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 1m27s
- Implemented TotalPlayerCountLogic to retrieve the total number of unique players within a specified time range. - Implemented TotalPlayTimeLogic to calculate the total playtime of players within a specified time range. - Created ServiceContext to manage database connections and initialize necessary tables. - Added types for total player count and total playtime requests and responses. - Set up the main server file to start the application with the necessary configurations. - Updated go.mod and go.sum for new dependencies.
This commit is contained in:
181
app/internal/types/types.go
Normal file
181
app/internal/types/types.go
Normal file
@@ -0,0 +1,181 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.8.4
|
||||
|
||||
package types
|
||||
|
||||
type PingReq struct {
|
||||
}
|
||||
|
||||
type PingResp struct {
|
||||
Ok bool `json:"ok"`
|
||||
}
|
||||
|
||||
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 {
|
||||
Messages []RecentChatMessageRespMessage `json:"messages"` // List of recent chat messages
|
||||
}
|
||||
|
||||
type RecentChatMessageRespMessage struct {
|
||||
SteamID64 string `json:"steamID64"` // Player's SteamID64
|
||||
UserName string `json:"userName"` // Player's username at the time of message
|
||||
Message string `json:"message"` // Chat message content
|
||||
TimeStamp int64 `json:"timeStamp"` // Message timestamp as Unix timestamp in milliseconds
|
||||
ServerName string `json:"serverName"` // Server name where the message was sent
|
||||
MapName string `json:"mapName"` // Map name where the message was sent
|
||||
ServerIP string `json:"serverIP"` // Server IP where the message was sent
|
||||
ServerPort int `json:"serverPort"` // Server port where the message was sent
|
||||
}
|
||||
|
||||
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 {
|
||||
Players []RecentJoinPlayerRespPlayer `json:"players"` // List of player SteamID64s who joined in the time range
|
||||
}
|
||||
|
||||
type RecentJoinPlayerRespPlayer struct {
|
||||
SteamID64 string `json:"steamID64"` // Player's SteamID64
|
||||
JoinTime int64 `json:"joinTime"` // Join time as Unix timestamp in milliseconds
|
||||
UserName string `json:"userName"` // Player's username at the time of joining
|
||||
PlayTime int64 `json:"playTime"` // Playtime in seconds since joining
|
||||
}
|
||||
|
||||
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 {
|
||||
Players []RecentPlayRespPlayer `json:"players"` // List of players who played in the time range
|
||||
}
|
||||
|
||||
type RecentPlayRespPlayer struct {
|
||||
SteamID64 string `json:"steamID64"` // Player's SteamID64
|
||||
UserName string `json:"userName"` // Player's username at the time of playing
|
||||
MapName string `json:"mapName"` // Map name where the player played
|
||||
PlayTime int64 `json:"playTime"` // Playtime in seconds during the time range
|
||||
}
|
||||
|
||||
type ServerListReq struct {
|
||||
}
|
||||
|
||||
type ServerListResp struct {
|
||||
ServerName string `json:"serverName"` // Server name
|
||||
ServerIP string `json:"serverIP"` // Server IP address
|
||||
ServerPort int `json:"serverPort"` // Server port
|
||||
Category string `json:"category"` // Server category
|
||||
MapName string `json:"mapName"` // Current map name
|
||||
HumanCount int `json:"humanCount"` // Current human player count
|
||||
BotCount int `json:"botCount"` // Bot count
|
||||
}
|
||||
|
||||
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 {
|
||||
Players []TopKillerRespPlayer `json:"players"` // List of top players by kill count
|
||||
}
|
||||
|
||||
type TopKillerRespPlayer struct {
|
||||
SteamID64 string `json:"steamID64"` // Player's SteamID64
|
||||
UserName string `json:"userName"` // Player's username at the time of playing
|
||||
KillCount int64 `json:"killCount"` // Kill count during the time range
|
||||
}
|
||||
|
||||
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 {
|
||||
Players []TopPlayTimeRespPlayer `json:"players"` // List of top players by playtime
|
||||
}
|
||||
|
||||
type TopPlayTimeRespPlayer struct {
|
||||
SteamID64 string `json:"steamID64"` // Player's SteamID64
|
||||
UserName string `json:"userName"` // Player's username at the time of playing
|
||||
PlayTime int64 `json:"playTime"` // Playtime in seconds during the time range
|
||||
}
|
||||
|
||||
type TotalChatMessageCountReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
PlayerFilter []string `json:"playerFilter"` // List of player SteamID64s to filter by (optional)
|
||||
}
|
||||
|
||||
type TotalChatMessageCountResp struct {
|
||||
TotalChatMessageCount int64 `json:"totalChatMessageCount"` // Total chat message count
|
||||
}
|
||||
|
||||
type TotalConnectCountReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
}
|
||||
|
||||
type TotalConnectCountResp struct {
|
||||
TotalConnectCount int64 `json:"totalConnectCount"` // Total connect count
|
||||
}
|
||||
|
||||
type TotalDamageCountReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
WeaponFilter []string `json:"weaponFilter"` // List of weapon names to filter by (optional)
|
||||
PlayerFilter []string `json:"playerFilter"` // List of player SteamID64s to filter by (optional)
|
||||
}
|
||||
|
||||
type TotalDamageCountResp struct {
|
||||
TotalDamageCount int64 `json:"totalDamageCount"` // Total damage count
|
||||
}
|
||||
|
||||
type TotalKillCountReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
HeadshotOnly bool `json:"headshotOnly"` // If true, count only headshot kills
|
||||
WeaponFilter []string `json:"weaponFilter"` // List of weapon names to filter by (optional)
|
||||
PlayerFilter []string `json:"playerFilter"` // List of player SteamID64s to filter by (optional)
|
||||
}
|
||||
|
||||
type TotalKillCountResp struct {
|
||||
TotalKillCount int64 `json:"totalKillCount"` // Total kill count
|
||||
}
|
||||
|
||||
type TotalPlayTimeReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
}
|
||||
|
||||
type TotalPlayTimeResp struct {
|
||||
TotalPlayTime int64 `json:"totalPlayTime"` // Total playtime in seconds
|
||||
}
|
||||
|
||||
type TotalPlayerCountReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
}
|
||||
|
||||
type TotalPlayerCountResp struct {
|
||||
Count int64 `json:"count"`
|
||||
}
|
||||
|
||||
type TotalPlayerJoinReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
}
|
||||
|
||||
type TotalPlayerJoinResp struct {
|
||||
Count int64 `json:"count"`
|
||||
}
|
||||
Reference in New Issue
Block a user