Yimaru-BackEnd/internal/domain/event_stats.go
Samuel Tariku 0ffba57ec5 feat: Refactor report generation and management
- Removed detailed event routes from the API.
- Added new report request routes for creating and fetching report requests.
- Introduced new domain models for report requests, including metadata and status handling.
- Implemented report request processing logic, including CSV generation for event interval reports.
- Enhanced company statistics handling with new domain models and service methods.
- Updated repository interfaces and implementations to support new report functionalities.
- Added error handling and logging for report file operations and notifications.
2025-10-28 00:51:52 +03:00

117 lines
4.1 KiB
Go

package domain
import (
"time"
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
)
type EventStats struct {
EventCount int64 `json:"event_count"`
TotalActiveEvents int64 `json:"total_active_events"`
TotalInActiveEvents int64 `json:"total_inactive_events"`
TotalFeaturedEvents int64 `json:"total_featured_events"`
TotalLeagues int64 `json:"total_leagues"`
Pending int64 `json:"pending"`
InPlay int64 `json:"in_play"`
ToBeFixed int64 `json:"to_be_fixed"`
Ended int64 `json:"ended"`
Postponed int64 `json:"postponed"`
Cancelled int64 `json:"cancelled"`
Walkover int64 `json:"walkover"`
Interrupted int64 `json:"interrupted"`
Abandoned int64 `json:"abandoned"`
Retired int64 `json:"retired"`
Suspended int64 `json:"suspended"`
DecidedByFa int64 `json:"decided_by_fa"`
Removed int64 `json:"removed"`
}
type EventStatsFilter struct {
Interval ValidDateInterval
LeagueID ValidInt64
SportID ValidInt32
}
type EventStatsByIntervalFilter struct {
Interval ValidDateInterval
LeagueID ValidInt64
SportID ValidInt32
}
type EventStatsByInterval struct {
Date time.Time `json:"date"`
EventCount int64 `json:"event_count"`
TotalActiveEvents int64 `json:"total_active_events"`
TotalInActiveEvents int64 `json:"total_inactive_events"`
TotalFeaturedEvents int64 `json:"total_featured_events"`
TotalLeagues int64 `json:"total_leagues"`
Pending int64 `json:"pending"`
InPlay int64 `json:"in_play"`
ToBeFixed int64 `json:"to_be_fixed"`
Ended int64 `json:"ended"`
Postponed int64 `json:"postponed"`
Cancelled int64 `json:"cancelled"`
Walkover int64 `json:"walkover"`
Interrupted int64 `json:"interrupted"`
Abandoned int64 `json:"abandoned"`
Retired int64 `json:"retired"`
Suspended int64 `json:"suspended"`
DecidedByFa int64 `json:"decided_by_fa"`
Removed int64 `json:"removed"`
}
func ConvertDBEventStats(stats dbgen.GetTotalEventStatsRow) EventStats {
return EventStats{
EventCount: stats.EventCount,
TotalActiveEvents: stats.TotalActiveEvents,
TotalInActiveEvents: stats.TotalInactiveEvents,
TotalFeaturedEvents: stats.TotalFeaturedEvents,
TotalLeagues: stats.TotalLeagues,
Pending: stats.Pending,
InPlay: stats.InPlay,
ToBeFixed: stats.ToBeFixed,
Ended: stats.Ended,
Postponed: stats.Postponed,
Cancelled: stats.Cancelled,
Walkover: stats.Walkover,
Interrupted: stats.Interrupted,
Abandoned: stats.Abandoned,
Retired: stats.Retired,
Suspended: stats.Suspended,
DecidedByFa: stats.DecidedByFa,
Removed: stats.Removed,
}
}
func ConvertDBEventStatsByInterval(stats dbgen.GetTotalEventStatsByIntervalRow) EventStatsByInterval {
return EventStatsByInterval{
Date: stats.Date.Time,
EventCount: stats.EventCount,
TotalActiveEvents: stats.TotalActiveEvents,
TotalInActiveEvents: stats.TotalInactiveEvents,
TotalFeaturedEvents: stats.TotalFeaturedEvents,
TotalLeagues: stats.TotalLeagues,
Pending: stats.Pending,
InPlay: stats.InPlay,
ToBeFixed: stats.ToBeFixed,
Ended: stats.Ended,
Postponed: stats.Postponed,
Cancelled: stats.Cancelled,
Walkover: stats.Walkover,
Interrupted: stats.Interrupted,
Abandoned: stats.Abandoned,
Retired: stats.Retired,
Suspended: stats.Suspended,
DecidedByFa: stats.DecidedByFa,
Removed: stats.Removed,
}
}
func ConvertDBEventStatsByIntervalList(stats []dbgen.GetTotalEventStatsByIntervalRow) []EventStatsByInterval {
result := make([]EventStatsByInterval, len(stats))
for i, e := range stats {
result[i] = ConvertDBEventStatsByInterval(e)
}
return result
}