chore: Updated version to v1.0.3
- Uncommented event service Crons
This commit is contained in:
parent
b90dc516be
commit
e66ef8a740
|
|
@ -37,108 +37,108 @@ func StartBetAPIDataFetchingCrons(
|
|||
spec string
|
||||
task func()
|
||||
}{
|
||||
// {
|
||||
// spec: "0 0 * * * *", // Every 1 hour
|
||||
// task: func() {
|
||||
// start := time.Now()
|
||||
// mongoLogger.Info("[BetAPI Event Fetching Crons] Began fetching upcoming events cron task", zap.Time("timestamp", time.Now()))
|
||||
// if err := eventService.FetchUpcomingEvents(context.Background()); err != nil {
|
||||
// mongoLogger.Error("[BetAPI Event Fetching Crons] Failed to fetch upcoming events",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// zap.Duration("duration", time.Since(start)),
|
||||
// zap.Error(err),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("[BetAPI Event Fetching Crons] Completed fetching upcoming events without errors",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// zap.Duration("duration", time.Since(start)),
|
||||
// )
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// spec: "0 0 * * * *", // Every 1 hour (since its takes that long to fetch all the events)
|
||||
// task: func() {
|
||||
// start := time.Now()
|
||||
// mongoLogger.Info("[BetAPI Pre-Match Odds Fetching Crons] Began fetching pre-match odds cron task",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// )
|
||||
// if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
|
||||
// mongoLogger.Error("[BetAPI Pre-Match Odds Fetching Crons] Failed to fetch pre-match odds",
|
||||
// zap.Error(err),
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// zap.Duration("duration", time.Since(start)),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("[BetAPI Pre-Match Odds Fetching Crons] Completed fetching pre-match odds without errors",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// zap.Duration("duration", time.Since(start)),
|
||||
// )
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// spec: "0 */5 * * * *", // Every 5 Minutes
|
||||
// task: func() {
|
||||
// start := time.Now()
|
||||
// mongoLogger.Info("[BetAPI Check And Update Expired Events Crons] Began update all expired events status cron task",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// )
|
||||
// if _, err := resultService.CheckAndUpdateExpiredB365Events(context.Background()); err != nil {
|
||||
// mongoLogger.Error("[BetAPI Check And Update Expired Events Crons] Failed to update expired events status",
|
||||
// zap.Error(err),
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// zap.Duration("duration", time.Since(start)),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("[BetAPI Check And Update Expired Events Crons] Completed expired events without errors",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// zap.Duration("duration", time.Since(start)),
|
||||
// )
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// spec: "0 */15 * * * *", // Every 15 Minutes
|
||||
// task: func() {
|
||||
// start := time.Now()
|
||||
// mongoLogger.Info("[BetAPI Fetch Result and Update Bets Crons] Began updating bets based on event results cron task")
|
||||
// if err := resultService.FetchB365ResultAndUpdateBets(context.Background()); err != nil {
|
||||
// mongoLogger.Error("[BetAPI Fetch Result and Update Bets Crons] Failed to process result",
|
||||
// zap.Error(err),
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// zap.Duration("duration", time.Since(start)),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("[BetAPI Fetch Result and Update Bets Crons] Completed processing all event result outcomes without errors",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// zap.Duration("duration", time.Since(start)),
|
||||
// )
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// spec: "0 0 0 * * 1", // Every Monday
|
||||
// task: func() {
|
||||
// mongoLogger.Info("[BetAPI Send Result Notification Crons] Began Send weekly result notification cron task",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// )
|
||||
// if err := resultService.CheckAndSendResultNotifications(context.Background(), time.Now().Add(-7*24*time.Hour)); err != nil {
|
||||
// mongoLogger.Error("[BetAPI Send Result Notification Crons] Failed to process result",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// zap.Error(err),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("[BetAPI Send Result Notification Crons] Completed sending weekly result notification without errors",
|
||||
// zap.Time("timestamp", time.Now()),
|
||||
// )
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
{
|
||||
spec: "0 0 * * * *", // Every 1 hour
|
||||
task: func() {
|
||||
start := time.Now()
|
||||
mongoLogger.Info("[BetAPI Event Fetching Crons] Began fetching upcoming events cron task", zap.Time("timestamp", time.Now()))
|
||||
if err := eventService.FetchUpcomingEvents(context.Background()); err != nil {
|
||||
mongoLogger.Error("[BetAPI Event Fetching Crons] Failed to fetch upcoming events",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
zap.Duration("duration", time.Since(start)),
|
||||
zap.Error(err),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("[BetAPI Event Fetching Crons] Completed fetching upcoming events without errors",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
zap.Duration("duration", time.Since(start)),
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
spec: "0 0 * * * *", // Every 1 hour (since its takes that long to fetch all the events)
|
||||
task: func() {
|
||||
start := time.Now()
|
||||
mongoLogger.Info("[BetAPI Pre-Match Odds Fetching Crons] Began fetching pre-match odds cron task",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
)
|
||||
if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
|
||||
mongoLogger.Error("[BetAPI Pre-Match Odds Fetching Crons] Failed to fetch pre-match odds",
|
||||
zap.Error(err),
|
||||
zap.Time("timestamp", time.Now()),
|
||||
zap.Duration("duration", time.Since(start)),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("[BetAPI Pre-Match Odds Fetching Crons] Completed fetching pre-match odds without errors",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
zap.Duration("duration", time.Since(start)),
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
spec: "0 */5 * * * *", // Every 5 Minutes
|
||||
task: func() {
|
||||
start := time.Now()
|
||||
mongoLogger.Info("[BetAPI Check And Update Expired Events Crons] Began update all expired events status cron task",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
)
|
||||
if _, err := resultService.CheckAndUpdateExpiredB365Events(context.Background()); err != nil {
|
||||
mongoLogger.Error("[BetAPI Check And Update Expired Events Crons] Failed to update expired events status",
|
||||
zap.Error(err),
|
||||
zap.Time("timestamp", time.Now()),
|
||||
zap.Duration("duration", time.Since(start)),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("[BetAPI Check And Update Expired Events Crons] Completed expired events without errors",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
zap.Duration("duration", time.Since(start)),
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
spec: "0 */15 * * * *", // Every 15 Minutes
|
||||
task: func() {
|
||||
start := time.Now()
|
||||
mongoLogger.Info("[BetAPI Fetch Result and Update Bets Crons] Began updating bets based on event results cron task")
|
||||
if err := resultService.FetchB365ResultAndUpdateBets(context.Background()); err != nil {
|
||||
mongoLogger.Error("[BetAPI Fetch Result and Update Bets Crons] Failed to process result",
|
||||
zap.Error(err),
|
||||
zap.Time("timestamp", time.Now()),
|
||||
zap.Duration("duration", time.Since(start)),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("[BetAPI Fetch Result and Update Bets Crons] Completed processing all event result outcomes without errors",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
zap.Duration("duration", time.Since(start)),
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
spec: "0 0 0 * * 1", // Every Monday
|
||||
task: func() {
|
||||
mongoLogger.Info("[BetAPI Send Result Notification Crons] Began Send weekly result notification cron task",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
)
|
||||
if err := resultService.CheckAndSendResultNotifications(context.Background(), time.Now().Add(-7*24*time.Hour)); err != nil {
|
||||
mongoLogger.Error("[BetAPI Send Result Notification Crons] Failed to process result",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
zap.Error(err),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("[BetAPI Send Result Notification Crons] Completed sending weekly result notification without errors",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, job := range schedule {
|
||||
job.task()
|
||||
// job.task()
|
||||
if _, err := c.AddFunc(job.spec, job.task); err != nil {
|
||||
mongoLogger.Error("[BetAPI Data Fetching Crons] Failed to schedule data fetching cron job",
|
||||
zap.Time("timestamp", time.Now()),
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func (a *App) initAppRoutes() {
|
|||
a.fiber.Get("/", func(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{
|
||||
"message": "Welcome to the FortuneBet API",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user