fix: user stats listing

This commit is contained in:
divyam234 2024-04-19 11:43:30 +05:30
parent b82dac8820
commit 7a7743c63f
2 changed files with 3 additions and 9 deletions

View file

@ -6,6 +6,6 @@ type Channel struct {
} }
type AccountStats struct { type AccountStats struct {
ChannelID int64 `json:"channelId"` ChannelID int64 `json:"channelId,omitempty"`
Bots []string `json:"bots"` Bots []string `json:"bots"`
} }

View file

@ -85,14 +85,8 @@ func (us *UserService) GetStats(c *gin.Context) (*schemas.AccountStats, *types.A
channelId int64 channelId int64
err error err error
) )
if c.Param("channelId") != "" {
channelId, _ = strconv.ParseInt(c.Param("channelId"), 10, 64) channelId, _ = GetDefaultChannel(c, us.db, userID)
} else {
channelId, err = GetDefaultChannel(c, us.db, userID)
if err != nil {
return nil, &types.AppError{Error: err, Code: http.StatusInternalServerError}
}
}
tokens, err := getBotsToken(c, us.db, userID, channelId) tokens, err := getBotsToken(c, us.db, userID, channelId)