You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.9 KiB
70 lines
1.9 KiB
|
1 year ago
|
package statistics
|
||
|
|
|
||
|
|
import (
|
||
|
|
"server/modules/backend/app"
|
||
|
|
"server/modules/backend/models"
|
||
|
|
utils "server/modules/backend/util"
|
||
|
|
"server/modules/backend/values"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
)
|
||
|
|
|
||
|
|
func PlayGameDataRoomGame(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
req := new(values.PlayGameDataReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
resp := values.PlayRoomGameDataResp{}
|
||
|
|
|
||
|
|
su, eu := utils.GetQueryUnix(req.Start, req.End)
|
||
|
|
|
||
|
|
var oneDay int64 = 24 * 60 * 60
|
||
|
|
for i := su; i < eu; i += oneDay {
|
||
|
|
s := i
|
||
|
|
e := i + oneDay
|
||
|
|
resp.List = append(resp.List, getRoomGameStatisticsInfo(&s, &e, req.Channel, &req.GameId))
|
||
|
|
}
|
||
|
|
|
||
|
|
a.Data = resp
|
||
|
|
}
|
||
|
|
|
||
|
|
func getRoomGameStatisticsInfo(s, e *int64, channel *int, gameId *int) values.RoomStatisticsInfo {
|
||
|
|
var res values.RoomStatisticsInfo
|
||
|
|
|
||
|
|
res.Date = *s
|
||
|
|
|
||
|
|
res.GameCount = models.GetGameTotal(s, e, channel, gameId, nil, nil)
|
||
|
|
res.PlayerCount = models.GetPlayerCount(s, e, channel, gameId, nil)
|
||
|
|
|
||
|
|
roomGameData := make(map[string]values.GameStatisticsData)
|
||
|
|
// for i := 0; i < len(common.RoomIDs); i++ {
|
||
|
|
// roomGameData[strconv.Itoa(common.RoomIDs[i])] = getStatisticsData(s, e, channel, gameId, &common.RoomIDs[i])
|
||
|
|
// }
|
||
|
|
res.RoomGameData = roomGameData
|
||
|
|
|
||
|
|
return res
|
||
|
|
}
|
||
|
|
|
||
|
|
func getStatisticsData(s, e *int64, channel *int, gameId *int, roomID *int) values.GameStatisticsData {
|
||
|
|
var GameStatisticsData values.GameStatisticsData
|
||
|
|
|
||
|
|
GameStatisticsData.GameCount = models.GetGameTotal(s, e, channel, gameId, roomID, nil)
|
||
|
|
GameStatisticsData.PlayerCount = models.GetPlayerCount(s, e, channel, gameId, roomID)
|
||
|
|
|
||
|
|
// isBreak := true
|
||
|
|
// Break := models.GetRoomGameCount(s, e, channel, gameId, roomID, &isBreak, nil, "UID")
|
||
|
|
|
||
|
|
// isWin := true
|
||
|
|
// Win := models.GetRoomGameCount(s, e, channel, gameId, roomID, nil, &isWin, "UUID.keyword")
|
||
|
|
|
||
|
|
// GameStatisticsData.Break = utils.GetPer(Break, GameStatisticsData.PlayerCount)
|
||
|
|
// GameStatisticsData.WinPer = utils.GetPer(Win, GameStatisticsData.GameCount)
|
||
|
|
|
||
|
|
return GameStatisticsData
|
||
|
|
}
|