- 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.
52 lines
935 B
Go
52 lines
935 B
Go
package domain
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
type EventSource string
|
|
|
|
const (
|
|
EVENT_SOURCE_BET365 EventSource = "b365api"
|
|
EVENT_SOURCE_BWIN EventSource = "bwin"
|
|
EVENT_SOURCE_BETFAIR EventSource = "bfair"
|
|
EVENT_SOURCE_1XBET EventSource = "1xbet"
|
|
EVENT_SOURCE_ENET EventSource = "enetpulse"
|
|
)
|
|
|
|
// --- EventSource Validation ---
|
|
func (s EventSource) IsValid() bool {
|
|
switch s {
|
|
case EVENT_SOURCE_BET365,
|
|
EVENT_SOURCE_BWIN,
|
|
EVENT_SOURCE_BETFAIR,
|
|
EVENT_SOURCE_1XBET,
|
|
EVENT_SOURCE_ENET:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func ParseEventSource(val string) (EventSource, error) {
|
|
s := EventSource(val)
|
|
if !s.IsValid() {
|
|
return "", fmt.Errorf("invalid EventSource: %q", val)
|
|
}
|
|
return s, nil
|
|
}
|
|
|
|
type ValidEventSource struct {
|
|
Value EventSource
|
|
Valid bool
|
|
}
|
|
|
|
func (v ValidEventSource) ToPG() pgtype.Text {
|
|
return pgtype.Text{
|
|
String: string(v.Value),
|
|
Valid: v.Valid,
|
|
}
|
|
}
|