Yimaru-BackEnd/internal/domain/bet_stats.go
Samuel Tariku 485cba3c9c feat: Add new stat stores and reporting functionalities for bets, branches, and wallets
- Introduced BetStatStore, BranchStatStore, and WalletStatStore interfaces for handling statistics.
- Implemented repository methods for fetching and updating bet, branch, and wallet statistics.
- Created reporting services for generating interval reports for bets, branches, companies, and wallets.
- Enhanced CSV writing functionality to support dynamic struct to CSV conversion.
- Added cron jobs for periodic updates of branch and wallet statistics.
- Updated wallet handler to include transaction statistics in the response.
2025-10-29 07:14:38 +03:00

50 lines
1.5 KiB
Go

package domain
import (
"time"
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
)
type BetStatsByInterval struct {
Date time.Time `json:"date"`
TotalBets int64 `json:"total_bets"`
TotalStake int64 `json:"total_stake"`
ActiveBets int64 `json:"active_bets"`
TotalWins int64 `json:"total_wins"`
TotalLosses int64 `json:"total_losses"`
WinBalance int64 `json:"win_balance"`
NumberOfUnsettled int64 `json:"number_of_unsettled"`
TotalUnsettledAmount int64 `json:"total_unsettled_amount"`
TotalShopBets int64 `json:"total_shop_bets"`
}
type BetStatsByIntervalFilter struct {
Interval ValidDateInterval
CompanyID ValidInt64
}
func ConvertDBBetStatsByInterval(stats dbgen.GetBetStatsByIntervalRow) BetStatsByInterval {
return BetStatsByInterval{
Date: stats.Date.Time,
TotalBets: stats.TotalBets,
TotalStake: stats.TotalStake,
ActiveBets: stats.ActiveBets,
TotalWins: stats.TotalWins,
TotalLosses: stats.TotalLosses,
WinBalance: stats.WinBalance,
NumberOfUnsettled: stats.NumberOfUnsettled,
TotalUnsettledAmount: stats.TotalUnsettledAmount,
TotalShopBets: stats.TotalShopBets,
}
}
func ConvertDBBetStatsByIntervalList(stats []dbgen.GetBetStatsByIntervalRow) []BetStatsByInterval {
result := make([]BetStatsByInterval, len(stats))
for i, e := range stats {
result[i] = ConvertDBBetStatsByInterval(e)
}
return result
}