fix: date filter
This commit is contained in:
parent
4c6fb73342
commit
cdc40397b9
|
|
@ -158,9 +158,7 @@ SELECT id,
|
|||
status,
|
||||
fetched_at
|
||||
FROM events
|
||||
WHERE is_live = false
|
||||
AND status = 'upcoming'
|
||||
AND start_time < now()
|
||||
WHERE start_time < now()
|
||||
ORDER BY start_time ASC;
|
||||
-- name: GetTotalEvents :one
|
||||
SELECT COUNT(*)
|
||||
|
|
|
|||
12
docs/docs.go
12
docs/docs.go
|
|
@ -1705,6 +1705,18 @@ const docTemplate = `{
|
|||
"description": "Sport ID Filter",
|
||||
"name": "sport_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Start Time",
|
||||
"name": "first_start_time",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "End Time",
|
||||
"name": "last_start_time",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
|
|
|||
|
|
@ -1697,6 +1697,18 @@
|
|||
"description": "Sport ID Filter",
|
||||
"name": "sport_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Start Time",
|
||||
"name": "first_start_time",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "End Time",
|
||||
"name": "last_start_time",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
|
|
|||
|
|
@ -2306,6 +2306,14 @@ paths:
|
|||
in: query
|
||||
name: sport_id
|
||||
type: string
|
||||
- description: Start Time
|
||||
in: query
|
||||
name: first_start_time
|
||||
type: string
|
||||
- description: End Time
|
||||
in: query
|
||||
name: last_start_time
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
|
|
|
|||
|
|
@ -118,9 +118,7 @@ SELECT id,
|
|||
status,
|
||||
fetched_at
|
||||
FROM events
|
||||
WHERE is_live = false
|
||||
AND status = 'upcoming'
|
||||
AND start_time < now()
|
||||
WHERE start_time < now()
|
||||
ORDER BY start_time ASC
|
||||
`
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ func (s *Store) GetPaginatedUpcomingEvents(ctx context.Context, limit domain.Val
|
|||
Valid: limit.Valid,
|
||||
},
|
||||
Offset: pgtype.Int4{
|
||||
Int32: int32(offset.Value),
|
||||
Int32: int32(offset.Value * limit.Value),
|
||||
Valid: offset.Valid,
|
||||
},
|
||||
FirstStartTime: pgtype.Timestamp{
|
||||
|
|
|
|||
|
|
@ -99,8 +99,7 @@ func (s *service) FetchLiveEvents(ctx context.Context) error {
|
|||
}
|
||||
|
||||
func (s *service) FetchUpcomingEvents(ctx context.Context) error {
|
||||
// sportIDs := []int{1, 18, 17}
|
||||
sportIDs := []int{18, 17}
|
||||
sportIDs := []int{1, 18, 17}
|
||||
|
||||
for _, sportID := range sportIDs {
|
||||
var totalPages int = 1
|
||||
|
|
@ -142,7 +141,6 @@ func (s *service) FetchUpcomingEvents(ctx context.Context) error {
|
|||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
} `json:"away"`
|
||||
|
||||
} `json:"results"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &data); err != nil || data.Success != 1 {
|
||||
|
|
@ -165,7 +163,7 @@ func (s *service) FetchUpcomingEvents(ctx context.Context) error {
|
|||
}
|
||||
|
||||
if !slices.Contains(domain.SupportedLeagues, leagueID) {
|
||||
fmt.Printf("⚠️ Skipping league %s (%d) as it is not supported\n", ev.League.Name, leagueID)
|
||||
// fmt.Printf("⚠️ Skipping league %s (%d) as it is not supported\n", ev.League.Name, leagueID)
|
||||
skippedLeague = append(skippedLeague, ev.League.Name)
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S
|
|||
}
|
||||
|
||||
for _, job := range schedule {
|
||||
// job.task()
|
||||
if _, err := c.AddFunc(job.spec, job.task); err != nil {
|
||||
log.Fatalf("Failed to schedule cron job: %v", err)
|
||||
}
|
||||
|
|
@ -82,7 +83,6 @@ func StartTicketCrons(ticketService ticket.Service) {
|
|||
}
|
||||
|
||||
for _, job := range schedule {
|
||||
job.task()
|
||||
if _, err := c.AddFunc(job.spec, job.task); err != nil {
|
||||
log.Fatalf("Failed to schedule cron job: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,8 @@ func (h *Handler) GetRawOddsByMarketID(c *fiber.Ctx) error {
|
|||
// @Param page_size query int false "Page size"
|
||||
// @Param league_id query string false "League ID Filter"
|
||||
// @Param sport_id query string false "Sport ID Filter"
|
||||
// @Param first_start_time query string false "Start Time"
|
||||
// @Param last_start_time query string false "End Time"
|
||||
// @Success 200 {array} domain.UpcomingEvent
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /prematch/events [get]
|
||||
|
|
@ -152,6 +154,7 @@ func (h *Handler) GetAllUpcomingEvents(c *fiber.Ctx) error {
|
|||
Value: int64(page - 1),
|
||||
Valid: true,
|
||||
}
|
||||
|
||||
events, total, err := h.eventSvc.GetPaginatedUpcomingEvents(
|
||||
c.Context(), limit, offset, leagueID, sportID, firstStartTime, lastStartTime)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user