- Introduced EventWithSettings and EventWithSettingsRes structs for enhanced event data handling. - Implemented conversion functions for creating and updating event settings. - Added support for fetching events with settings from the database. - Created new report data structures for comprehensive reporting capabilities. - Implemented event statistics retrieval and filtering by league and sport. - Added handlers for event statistics endpoints in the web server. - Introduced DateInterval type for managing time intervals in reports.
32 lines
505 B
Go
32 lines
505 B
Go
package domain
|
|
|
|
import "fmt"
|
|
|
|
type DateInterval string
|
|
|
|
var (
|
|
MonthInterval DateInterval = "month"
|
|
WeekInterval DateInterval = "week"
|
|
DayInterval DateInterval = "day"
|
|
)
|
|
|
|
func (d DateInterval) IsValid() bool {
|
|
switch d {
|
|
case MonthInterval,
|
|
WeekInterval,
|
|
DayInterval:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
|
|
}
|
|
|
|
func ParseDateInterval(val string) (DateInterval, error) {
|
|
d := DateInterval(val)
|
|
if !d.IsValid() {
|
|
return "", fmt.Errorf("invalid date interval: %q", val)
|
|
}
|
|
return d, nil
|
|
}
|