fix: top-league not showing up
This commit is contained in:
parent
156f83ddc5
commit
2875e9b85c
|
|
@ -514,7 +514,7 @@ CREATE TABLE IF NOT EXISTS raffle_tickets (
|
|||
id SERIAL PRIMARY KEY,
|
||||
raffle_id INT NOT NULL REFERENCES raffles(id) ON DELETE CASCADE,
|
||||
user_id INT NOT NULL,
|
||||
is_active BOOL DEFAULT true,
|
||||
is_active BOOL DEFAULT true
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS raffle_winners (
|
||||
id SERIAL PRIMARY KEY,
|
||||
|
|
@ -737,4 +737,4 @@ ADD CONSTRAINT fk_event_settings_company FOREIGN KEY (company_id) REFERENCES com
|
|||
ADD CONSTRAINT fk_event_settings_event FOREIGN KEY (event_id) REFERENCES events (id) ON DELETE CASCADE;
|
||||
ALTER TABLE company_odd_settings
|
||||
ADD CONSTRAINT fk_odds_settings_company FOREIGN KEY (company_id) REFERENCES companies (id) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT fk_odds_settings_odds_market FOREIGN KEY (odds_market_id) REFERENCES odds_market (id) ON DELETE CASCADE;
|
||||
ADD CONSTRAINT fk_odds_settings_odds_market FOREIGN KEY (odds_market_id) REFERENCES odds_market (id) ON DELETE CASCADE;
|
||||
|
|
@ -187,7 +187,13 @@ WHERE is_live = false
|
|||
)
|
||||
AND (
|
||||
ces.is_featured = sqlc.narg('is_featured')
|
||||
OR e.default_is_featured = sqlc.narg('is_featured')
|
||||
OR sqlc.narg('is_featured') IS NULL
|
||||
)
|
||||
AND (
|
||||
ces.is_active = sqlc.narg('is_active')
|
||||
OR e.default_is_active = sqlc.narg('is_active')
|
||||
OR sqlc.narg('is_active') IS NULL
|
||||
);
|
||||
-- name: GetEventsWithSettings :many
|
||||
SELECT e.*,
|
||||
|
|
@ -231,10 +237,17 @@ WHERE start_time > now()
|
|||
AND (
|
||||
l.country_code = sqlc.narg('country_code')
|
||||
OR sqlc.narg('country_code') IS NULL
|
||||
) AND (
|
||||
ces.is_featured = sqlc.narg('is_featured')
|
||||
OR sqlc.narg('is_featured') IS NULL
|
||||
)
|
||||
)
|
||||
AND (
|
||||
ces.is_featured = sqlc.narg('is_featured')
|
||||
OR e.default_is_featured = sqlc.narg('is_featured')
|
||||
OR sqlc.narg('is_featured') IS NULL
|
||||
)
|
||||
AND (
|
||||
ces.is_active = sqlc.narg('is_active')
|
||||
OR e.default_is_active = sqlc.narg('is_active')
|
||||
OR sqlc.narg('is_active') IS NULL
|
||||
)
|
||||
ORDER BY start_time ASC
|
||||
LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset');
|
||||
-- name: GetUpcomingByID :one
|
||||
|
|
|
|||
|
|
@ -42,14 +42,11 @@ WHERE (
|
|||
)
|
||||
ORDER BY name ASC
|
||||
LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset');
|
||||
-- name: GetAllLeaguesWithSettings :many
|
||||
SELECT l.*,
|
||||
cls.company_id,
|
||||
COALESCE(cls.is_active, l.default_is_active) AS is_active,
|
||||
COALESCE(cls.is_featured, l.default_is_featured) AS is_featured,
|
||||
cls.updated_at
|
||||
-- name: GetTotalLeaguesWithSettings :one
|
||||
SELECT COUNT(*)
|
||||
FROM leagues l
|
||||
LEFT JOIN company_league_settings cls ON l.id = cls.league_id AND company_id = $1
|
||||
LEFT JOIN company_league_settings cls ON l.id = cls.league_id
|
||||
AND company_id = $1
|
||||
WHERE (
|
||||
country_code = sqlc.narg('country_code')
|
||||
OR sqlc.narg('country_code') IS NULL
|
||||
|
|
@ -60,10 +57,43 @@ WHERE (
|
|||
)
|
||||
AND (
|
||||
is_active = sqlc.narg('is_active')
|
||||
OR default_is_active = sqlc.narg('is_active')
|
||||
OR sqlc.narg('is_active') IS NULL
|
||||
)
|
||||
AND (
|
||||
is_featured = sqlc.narg('is_featured')
|
||||
OR default_is_featured = sqlc.narg('is_featured')
|
||||
OR sqlc.narg('is_featured') IS NULL
|
||||
)
|
||||
AND (
|
||||
name ILIKE '%' || sqlc.narg('query') || '%'
|
||||
OR sqlc.narg('query') IS NULL
|
||||
);
|
||||
-- name: GetAllLeaguesWithSettings :many
|
||||
SELECT l.*,
|
||||
cls.company_id,
|
||||
COALESCE(cls.is_active, l.default_is_active) AS is_active,
|
||||
COALESCE(cls.is_featured, l.default_is_featured) AS is_featured,
|
||||
cls.updated_at
|
||||
FROM leagues l
|
||||
LEFT JOIN company_league_settings cls ON l.id = cls.league_id
|
||||
AND company_id = $1
|
||||
WHERE (
|
||||
country_code = sqlc.narg('country_code')
|
||||
OR sqlc.narg('country_code') IS NULL
|
||||
)
|
||||
AND (
|
||||
sport_id = sqlc.narg('sport_id')
|
||||
OR sqlc.narg('sport_id') IS NULL
|
||||
)
|
||||
AND (
|
||||
is_active = sqlc.narg('is_active')
|
||||
OR default_is_active = sqlc.narg('is_active')
|
||||
OR sqlc.narg('is_active') IS NULL
|
||||
)
|
||||
AND (
|
||||
is_featured = sqlc.narg('is_featured')
|
||||
OR default_is_featured = sqlc.narg('is_featured')
|
||||
OR sqlc.narg('is_featured') IS NULL
|
||||
)
|
||||
AND (
|
||||
|
|
|
|||
|
|
@ -218,12 +218,19 @@ WHERE start_time > now()
|
|||
AND (
|
||||
l.country_code = $7
|
||||
OR $7 IS NULL
|
||||
) AND (
|
||||
ces.is_featured = $8
|
||||
OR $8 IS NULL
|
||||
)
|
||||
)
|
||||
AND (
|
||||
ces.is_featured = $8
|
||||
OR e.default_is_featured = $8
|
||||
OR $8 IS NULL
|
||||
)
|
||||
AND (
|
||||
ces.is_active = $9
|
||||
OR e.default_is_active = $9
|
||||
OR $9 IS NULL
|
||||
)
|
||||
ORDER BY start_time ASC
|
||||
LIMIT $10 OFFSET $9
|
||||
LIMIT $11 OFFSET $10
|
||||
`
|
||||
|
||||
type GetEventsWithSettingsParams struct {
|
||||
|
|
@ -235,6 +242,7 @@ type GetEventsWithSettingsParams struct {
|
|||
FirstStartTime pgtype.Timestamp `json:"first_start_time"`
|
||||
CountryCode pgtype.Text `json:"country_code"`
|
||||
IsFeatured pgtype.Bool `json:"is_featured"`
|
||||
IsActive pgtype.Bool `json:"is_active"`
|
||||
Offset pgtype.Int4 `json:"offset"`
|
||||
Limit pgtype.Int4 `json:"limit"`
|
||||
}
|
||||
|
|
@ -283,6 +291,7 @@ func (q *Queries) GetEventsWithSettings(ctx context.Context, arg GetEventsWithSe
|
|||
arg.FirstStartTime,
|
||||
arg.CountryCode,
|
||||
arg.IsFeatured,
|
||||
arg.IsActive,
|
||||
arg.Offset,
|
||||
arg.Limit,
|
||||
)
|
||||
|
|
@ -531,8 +540,14 @@ WHERE is_live = false
|
|||
)
|
||||
AND (
|
||||
ces.is_featured = $8
|
||||
OR e.default_is_featured = $8
|
||||
OR $8 IS NULL
|
||||
)
|
||||
AND (
|
||||
ces.is_active = $9
|
||||
OR e.default_is_active = $9
|
||||
OR $9 IS NULL
|
||||
)
|
||||
`
|
||||
|
||||
type GetTotalCompanyEventsParams struct {
|
||||
|
|
@ -544,6 +559,7 @@ type GetTotalCompanyEventsParams struct {
|
|||
FirstStartTime pgtype.Timestamp `json:"first_start_time"`
|
||||
CountryCode pgtype.Text `json:"country_code"`
|
||||
IsFeatured pgtype.Bool `json:"is_featured"`
|
||||
IsActive pgtype.Bool `json:"is_active"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetTotalCompanyEvents(ctx context.Context, arg GetTotalCompanyEventsParams) (int64, error) {
|
||||
|
|
@ -556,6 +572,7 @@ func (q *Queries) GetTotalCompanyEvents(ctx context.Context, arg GetTotalCompany
|
|||
arg.FirstStartTime,
|
||||
arg.CountryCode,
|
||||
arg.IsFeatured,
|
||||
arg.IsActive,
|
||||
)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
|
|
|
|||
|
|
@ -102,7 +102,8 @@ SELECT l.id, l.name, l.img_url, l.country_code, l.bet365_id, l.sport_id, l.defau
|
|||
COALESCE(cls.is_featured, l.default_is_featured) AS is_featured,
|
||||
cls.updated_at
|
||||
FROM leagues l
|
||||
LEFT JOIN company_league_settings cls ON l.id = cls.league_id AND company_id = $1
|
||||
LEFT JOIN company_league_settings cls ON l.id = cls.league_id
|
||||
AND company_id = $1
|
||||
WHERE (
|
||||
country_code = $2
|
||||
OR $2 IS NULL
|
||||
|
|
@ -113,10 +114,12 @@ WHERE (
|
|||
)
|
||||
AND (
|
||||
is_active = $4
|
||||
OR default_is_active = $4
|
||||
OR $4 IS NULL
|
||||
)
|
||||
AND (
|
||||
is_featured = $5
|
||||
OR default_is_featured = $5
|
||||
OR $5 IS NULL
|
||||
)
|
||||
AND (
|
||||
|
|
@ -196,6 +199,58 @@ func (q *Queries) GetAllLeaguesWithSettings(ctx context.Context, arg GetAllLeagu
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const GetTotalLeaguesWithSettings = `-- name: GetTotalLeaguesWithSettings :one
|
||||
SELECT COUNT(*)
|
||||
FROM leagues l
|
||||
LEFT JOIN company_league_settings cls ON l.id = cls.league_id
|
||||
AND company_id = $1
|
||||
WHERE (
|
||||
country_code = $2
|
||||
OR $2 IS NULL
|
||||
)
|
||||
AND (
|
||||
sport_id = $3
|
||||
OR $3 IS NULL
|
||||
)
|
||||
AND (
|
||||
is_active = $4
|
||||
OR default_is_active = $4
|
||||
OR $4 IS NULL
|
||||
)
|
||||
AND (
|
||||
is_featured = $5
|
||||
OR default_is_featured = $5
|
||||
OR $5 IS NULL
|
||||
)
|
||||
AND (
|
||||
name ILIKE '%' || $6 || '%'
|
||||
OR $6 IS NULL
|
||||
)
|
||||
`
|
||||
|
||||
type GetTotalLeaguesWithSettingsParams struct {
|
||||
CompanyID int64 `json:"company_id"`
|
||||
CountryCode pgtype.Text `json:"country_code"`
|
||||
SportID pgtype.Int4 `json:"sport_id"`
|
||||
IsActive pgtype.Bool `json:"is_active"`
|
||||
IsFeatured pgtype.Bool `json:"is_featured"`
|
||||
Query pgtype.Text `json:"query"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetTotalLeaguesWithSettings(ctx context.Context, arg GetTotalLeaguesWithSettingsParams) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, GetTotalLeaguesWithSettings,
|
||||
arg.CompanyID,
|
||||
arg.CountryCode,
|
||||
arg.SportID,
|
||||
arg.IsActive,
|
||||
arg.IsFeatured,
|
||||
arg.Query,
|
||||
)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const InsertLeague = `-- name: InsertLeague :exec
|
||||
INSERT INTO leagues (
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -502,6 +502,14 @@ type RaffleTicket struct {
|
|||
IsActive pgtype.Bool `json:"is_active"`
|
||||
}
|
||||
|
||||
type RaffleWinner struct {
|
||||
ID int32 `json:"id"`
|
||||
RaffleID int32 `json:"raffle_id"`
|
||||
UserID int32 `json:"user_id"`
|
||||
Rank int32 `json:"rank"`
|
||||
CreatedAt pgtype.Timestamp `json:"created_at"`
|
||||
}
|
||||
|
||||
type ReferralCode struct {
|
||||
ID int64 `json:"id"`
|
||||
ReferralCode string `json:"referral_code"`
|
||||
|
|
@ -514,14 +522,6 @@ type ReferralCode struct {
|
|||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
type RaffleWinner struct {
|
||||
ID int32 `json:"id"`
|
||||
RaffleID int32 `json:"raffle_id"`
|
||||
UserID int32 `json:"user_id"`
|
||||
Rank int32 `json:"rank"`
|
||||
CreatedAt pgtype.Timestamp `json:"created_at"`
|
||||
}
|
||||
|
||||
type RefreshToken struct {
|
||||
ID int64 `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ type EventFilter struct {
|
|||
Offset ValidInt32
|
||||
MatchStatus ValidString // e.g., "upcoming", "in_play", "ended"
|
||||
Featured ValidBool
|
||||
Active ValidBool
|
||||
}
|
||||
|
||||
func ConvertDBEvent(event dbgen.EventWithCountry) BaseEvent {
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ func ConvertDBBaseLeagues(leagues []dbgen.League) []BaseLeague {
|
|||
return result
|
||||
}
|
||||
|
||||
func ConvertDBLeagueWithSetting(lws dbgen.LeagueWithSetting) LeagueWithSettings {
|
||||
func ConvertDBLeagueWithSetting(lws dbgen.GetAllLeaguesWithSettingsRow) LeagueWithSettings {
|
||||
return LeagueWithSettings{
|
||||
ID: lws.ID,
|
||||
Name: lws.Name,
|
||||
|
|
@ -167,7 +167,7 @@ func ConvertDBLeagueWithSetting(lws dbgen.LeagueWithSetting) LeagueWithSettings
|
|||
}
|
||||
}
|
||||
|
||||
func ConvertDBLeagueWithSettings(lws []dbgen.LeagueWithSetting) []LeagueWithSettings {
|
||||
func ConvertDBLeagueWithSettings(lws []dbgen.GetAllLeaguesWithSettingsRow) []LeagueWithSettings {
|
||||
result := make([]LeagueWithSettings, len(lws))
|
||||
for i, league := range lws {
|
||||
result[i] = ConvertDBLeagueWithSetting(league)
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ func (s *Store) GetEventsWithSettings(ctx context.Context, companyID int64, filt
|
|||
LastStartTime: filter.LastStartTime.ToPG(),
|
||||
CountryCode: filter.CountryCode.ToPG(),
|
||||
IsFeatured: filter.Featured.ToPG(),
|
||||
IsActive: filter.Active.ToPG(),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -101,6 +102,7 @@ func (s *Store) GetEventsWithSettings(ctx context.Context, companyID int64, filt
|
|||
LastStartTime: filter.LastStartTime.ToPG(),
|
||||
CountryCode: filter.CountryCode.ToPG(),
|
||||
IsFeatured: filter.Featured.ToPG(),
|
||||
IsActive: filter.Active.ToPG(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ func (s *Store) GetAllLeagues(ctx context.Context, filter domain.LeagueFilter) (
|
|||
return domain.ConvertDBBaseLeagues(l), nil
|
||||
}
|
||||
|
||||
func (s *Store) GetAllLeaguesByCompany(ctx context.Context, companyID int64, filter domain.LeagueFilter) ([]domain.LeagueWithSettings, error) {
|
||||
func (s *Store) GetAllLeaguesByCompany(ctx context.Context, companyID int64, filter domain.LeagueFilter) ([]domain.LeagueWithSettings, int64, error) {
|
||||
|
||||
l, err := s.queries.GetAllLeaguesWithSettings(ctx, dbgen.GetAllLeaguesWithSettingsParams{
|
||||
Query: filter.Query.ToPG(),
|
||||
CompanyID: companyID,
|
||||
|
|
@ -52,38 +53,26 @@ func (s *Store) GetAllLeaguesByCompany(ctx context.Context, companyID int64, fil
|
|||
Valid: filter.Offset.Valid,
|
||||
},
|
||||
IsFeatured: filter.IsFeatured.ToPG(),
|
||||
IsActive: filter.IsActive.ToPG(),
|
||||
IsActive: filter.IsActive.ToPG(),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
result := make([]domain.LeagueWithSettings, len(l))
|
||||
for i, league := range l {
|
||||
result[i] = domain.LeagueWithSettings{
|
||||
ID: league.ID,
|
||||
Name: league.Name,
|
||||
CompanyID: league.CompanyID.Int64,
|
||||
CountryCode: domain.ValidString{
|
||||
Value: league.CountryCode.String,
|
||||
Valid: league.CountryCode.Valid,
|
||||
},
|
||||
Bet365ID: domain.ValidInt32{
|
||||
Value: league.Bet365ID.Int32,
|
||||
Valid: league.Bet365ID.Valid,
|
||||
},
|
||||
IsActive: league.IsActive,
|
||||
SportID: league.SportID,
|
||||
IsFeatured: league.IsFeatured,
|
||||
UpdatedAt: league.UpdatedAt.Time,
|
||||
total, err := s.queries.GetTotalLeaguesWithSettings(ctx, dbgen.GetTotalLeaguesWithSettingsParams{
|
||||
Query: filter.Query.ToPG(),
|
||||
CompanyID: companyID,
|
||||
CountryCode: filter.CountryCode.ToPG(),
|
||||
SportID: filter.SportID.ToPG(),
|
||||
IsFeatured: filter.IsFeatured.ToPG(),
|
||||
IsActive: filter.IsActive.ToPG(),
|
||||
})
|
||||
|
||||
DefaultIsActive: league.DefaultIsActive,
|
||||
DefaultIsFeatured: league.DefaultIsFeatured,
|
||||
}
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return domain.ConvertDBLeagueWithSettings(l), total, nil
|
||||
}
|
||||
|
||||
func (s *Store) CheckLeagueSupport(ctx context.Context, leagueID int64, companyID int64) (bool, error) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ type Service interface {
|
|||
SaveLeague(ctx context.Context, league domain.CreateLeague) error
|
||||
SaveLeagueSettings(ctx context.Context, leagueSettings domain.CreateLeagueSettings) error
|
||||
GetAllLeagues(ctx context.Context, filter domain.LeagueFilter) ([]domain.BaseLeague, error)
|
||||
GetAllLeaguesByCompany(ctx context.Context, companyID int64, filter domain.LeagueFilter) ([]domain.LeagueWithSettings, error)
|
||||
GetAllLeaguesByCompany(ctx context.Context, companyID int64, filter domain.LeagueFilter) ([]domain.LeagueWithSettings, int64, error)
|
||||
CheckLeagueSupport(ctx context.Context, leagueID int64, companyID int64) (bool, error)
|
||||
UpdateLeague(ctx context.Context, league domain.UpdateLeague) error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ func (s *service) GetAllLeagues(ctx context.Context, filter domain.LeagueFilter)
|
|||
return s.store.GetAllLeagues(ctx, filter)
|
||||
}
|
||||
|
||||
func (s *service) GetAllLeaguesByCompany(ctx context.Context, companyID int64, filter domain.LeagueFilter) ([]domain.LeagueWithSettings, error) {
|
||||
func (s *service) GetAllLeaguesByCompany(ctx context.Context, companyID int64, filter domain.LeagueFilter) ([]domain.LeagueWithSettings, int64, error) {
|
||||
return s.store.GetAllLeaguesByCompany(ctx, companyID, filter)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,71 +26,71 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S
|
|||
spec string
|
||||
task func()
|
||||
}{
|
||||
{
|
||||
spec: "0 0 * * * *", // Every 1 hour
|
||||
task: func() {
|
||||
mongoLogger.Info("Began fetching upcoming events cron task")
|
||||
if err := eventService.FetchUpcomingEvents(context.Background()); err != nil {
|
||||
mongoLogger.Error("Failed to fetch upcoming events",
|
||||
zap.Error(err),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("Completed fetching upcoming events without errors")
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
spec: "0 0 * * * *", // Every 1 hour (since its takes that long to fetch all the events)
|
||||
task: func() {
|
||||
mongoLogger.Info("Began fetching non live odds cron task")
|
||||
if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
|
||||
mongoLogger.Error("Failed to fetch non live odds",
|
||||
zap.Error(err),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("Completed fetching non live odds without errors")
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
spec: "0 */5 * * * *", // Every 5 Minutes
|
||||
task: func() {
|
||||
mongoLogger.Info("Began update all expired events status cron task")
|
||||
if _, err := resultService.CheckAndUpdateExpiredEvents(context.Background()); err != nil {
|
||||
mongoLogger.Error("Failed to update expired events status",
|
||||
zap.Error(err),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("Completed expired events without errors")
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
spec: "0 */15 * * * *", // Every 15 Minutes
|
||||
task: func() {
|
||||
mongoLogger.Info("Began fetching results for upcoming events cron task")
|
||||
if err := resultService.FetchAndProcessResults(context.Background()); err != nil {
|
||||
mongoLogger.Error("Failed to process result",
|
||||
zap.Error(err),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("Completed processing all event result outcomes without errors")
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
spec: "0 0 0 * * *", // Every Day
|
||||
task: func() {
|
||||
mongoLogger.Info("Began Send daily result notification cron task")
|
||||
if err := resultService.CheckAndSendResultNotifications(context.Background(), time.Now().Add(-24*time.Hour)); err != nil {
|
||||
mongoLogger.Error("Failed to process result",
|
||||
zap.Error(err),
|
||||
)
|
||||
} else {
|
||||
mongoLogger.Info("Completed sending daily result notification without errors")
|
||||
}
|
||||
},
|
||||
},
|
||||
// {
|
||||
// spec: "0 0 * * * *", // Every 1 hour
|
||||
// task: func() {
|
||||
// mongoLogger.Info("Began fetching upcoming events cron task")
|
||||
// if err := eventService.FetchUpcomingEvents(context.Background()); err != nil {
|
||||
// mongoLogger.Error("Failed to fetch upcoming events",
|
||||
// zap.Error(err),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("Completed fetching upcoming events without errors")
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// spec: "0 0 * * * *", // Every 1 hour (since its takes that long to fetch all the events)
|
||||
// task: func() {
|
||||
// mongoLogger.Info("Began fetching non live odds cron task")
|
||||
// if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
|
||||
// mongoLogger.Error("Failed to fetch non live odds",
|
||||
// zap.Error(err),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("Completed fetching non live odds without errors")
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// spec: "0 */5 * * * *", // Every 5 Minutes
|
||||
// task: func() {
|
||||
// mongoLogger.Info("Began update all expired events status cron task")
|
||||
// if _, err := resultService.CheckAndUpdateExpiredEvents(context.Background()); err != nil {
|
||||
// mongoLogger.Error("Failed to update expired events status",
|
||||
// zap.Error(err),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("Completed expired events without errors")
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// spec: "0 */15 * * * *", // Every 15 Minutes
|
||||
// task: func() {
|
||||
// mongoLogger.Info("Began fetching results for upcoming events cron task")
|
||||
// if err := resultService.FetchAndProcessResults(context.Background()); err != nil {
|
||||
// mongoLogger.Error("Failed to process result",
|
||||
// zap.Error(err),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("Completed processing all event result outcomes without errors")
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// spec: "0 0 0 * * *", // Every Day
|
||||
// task: func() {
|
||||
// mongoLogger.Info("Began Send daily result notification cron task")
|
||||
// if err := resultService.CheckAndSendResultNotifications(context.Background(), time.Now().Add(-24*time.Hour)); err != nil {
|
||||
// mongoLogger.Error("Failed to process result",
|
||||
// zap.Error(err),
|
||||
// )
|
||||
// } else {
|
||||
// mongoLogger.Info("Completed sending daily result notification without errors")
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
}
|
||||
|
||||
for _, job := range schedule {
|
||||
|
|
|
|||
|
|
@ -303,6 +303,7 @@ func (h *Handler) GetTenantUpcomingEvents(c *fiber.Ctx) error {
|
|||
Offset: offset,
|
||||
CountryCode: countryCode,
|
||||
Featured: isFeatured,
|
||||
Active: domain.ValidBool{Value: true, Valid: true},
|
||||
})
|
||||
|
||||
// fmt.Printf("League ID: %v", leagueID)
|
||||
|
|
@ -347,12 +348,11 @@ func (h *Handler) GetTopLeagues(c *fiber.Ctx) error {
|
|||
return fiber.NewError(fiber.StatusBadRequest, "invalid company id")
|
||||
}
|
||||
|
||||
leagues, err := h.leagueSvc.GetAllLeaguesByCompany(c.Context(), companyID.Value, domain.LeagueFilter{
|
||||
leagues, _, err := h.leagueSvc.GetAllLeaguesByCompany(c.Context(), companyID.Value, domain.LeagueFilter{
|
||||
IsFeatured: domain.ValidBool{
|
||||
Value: true,
|
||||
Valid: true,
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -371,6 +371,7 @@ func (h *Handler) GetTopLeagues(c *fiber.Ctx) error {
|
|||
Value: league.ID,
|
||||
Valid: true,
|
||||
},
|
||||
Active: domain.ValidBool{Value: true, Valid: true},
|
||||
})
|
||||
if err != nil {
|
||||
h.InternalServerErrorLogger().Warn("Error while fetching events for top league",
|
||||
|
|
@ -570,7 +571,6 @@ type SetEventIsMonitoredReq struct {
|
|||
IsMonitored bool `json:"is_monitored"`
|
||||
}
|
||||
|
||||
|
||||
// SetEventIsMonitored godoc
|
||||
// @Summary update the event is_monitored
|
||||
// @Description Update the event is_monitored
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ func (h *Handler) GetAllLeagues(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
res := domain.ConvertBaseLeagueResList(leagues)
|
||||
|
||||
|
||||
return response.WriteJSON(c, fiber.StatusOK, "All leagues retrieved", res, nil)
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ func (h *Handler) GetAllLeaguesForTenant(c *fiber.Ctx) error {
|
|||
zap.Bool("sport_id_valid", sportID.Valid),
|
||||
}
|
||||
|
||||
leagues, err := h.leagueSvc.GetAllLeaguesByCompany(c.Context(), companyID.Value, domain.LeagueFilter{
|
||||
leagues, total, err := h.leagueSvc.GetAllLeaguesByCompany(c.Context(), companyID.Value, domain.LeagueFilter{
|
||||
CountryCode: countryCode,
|
||||
IsActive: isActive,
|
||||
SportID: sportID,
|
||||
|
|
@ -206,7 +206,7 @@ func (h *Handler) GetAllLeaguesForTenant(c *fiber.Ctx) error {
|
|||
|
||||
res := domain.ConvertLeagueWithSettingResList(leagues)
|
||||
|
||||
return response.WriteJSON(c, fiber.StatusOK, "All leagues retrieved", res, nil)
|
||||
return response.WritePaginatedJSON(c, fiber.StatusOK, "All leagues retrieved", res, nil, page, int(total))
|
||||
}
|
||||
|
||||
type SetLeagueActiveReq struct {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user