fix: top-league not showing up

This commit is contained in:
Samuel Tariku 2025-09-17 15:43:27 +03:00
parent 156f83ddc5
commit 2875e9b85c
15 changed files with 235 additions and 128 deletions

View File

@ -514,7 +514,7 @@ CREATE TABLE IF NOT EXISTS raffle_tickets (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
raffle_id INT NOT NULL REFERENCES raffles(id) ON DELETE CASCADE, raffle_id INT NOT NULL REFERENCES raffles(id) ON DELETE CASCADE,
user_id INT NOT NULL, user_id INT NOT NULL,
is_active BOOL DEFAULT true, is_active BOOL DEFAULT true
); );
CREATE TABLE IF NOT EXISTS raffle_winners ( CREATE TABLE IF NOT EXISTS raffle_winners (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,

View File

@ -187,7 +187,13 @@ WHERE is_live = false
) )
AND ( AND (
ces.is_featured = sqlc.narg('is_featured') ces.is_featured = sqlc.narg('is_featured')
OR e.default_is_featured = sqlc.narg('is_featured')
OR sqlc.narg('is_featured') IS NULL 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 -- name: GetEventsWithSettings :many
SELECT e.*, SELECT e.*,
@ -231,10 +237,17 @@ WHERE start_time > now()
AND ( AND (
l.country_code = sqlc.narg('country_code') l.country_code = sqlc.narg('country_code')
OR sqlc.narg('country_code') IS NULL OR sqlc.narg('country_code') IS NULL
) AND ( )
ces.is_featured = sqlc.narg('is_featured') AND (
OR sqlc.narg('is_featured') IS NULL 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 ORDER BY start_time ASC
LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset'); LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset');
-- name: GetUpcomingByID :one -- name: GetUpcomingByID :one

View File

@ -42,14 +42,11 @@ WHERE (
) )
ORDER BY name ASC ORDER BY name ASC
LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset'); LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset');
-- name: GetAllLeaguesWithSettings :many -- name: GetTotalLeaguesWithSettings :one
SELECT l.*, SELECT COUNT(*)
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 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 ( WHERE (
country_code = sqlc.narg('country_code') country_code = sqlc.narg('country_code')
OR sqlc.narg('country_code') IS NULL OR sqlc.narg('country_code') IS NULL
@ -60,10 +57,43 @@ WHERE (
) )
AND ( AND (
is_active = sqlc.narg('is_active') is_active = sqlc.narg('is_active')
OR default_is_active = sqlc.narg('is_active')
OR sqlc.narg('is_active') IS NULL OR sqlc.narg('is_active') IS NULL
) )
AND ( AND (
is_featured = sqlc.narg('is_featured') 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 OR sqlc.narg('is_featured') IS NULL
) )
AND ( AND (

View File

@ -218,12 +218,19 @@ WHERE start_time > now()
AND ( AND (
l.country_code = $7 l.country_code = $7
OR $7 IS NULL OR $7 IS NULL
) AND ( )
ces.is_featured = $8 AND (
OR $8 IS NULL 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 ORDER BY start_time ASC
LIMIT $10 OFFSET $9 LIMIT $11 OFFSET $10
` `
type GetEventsWithSettingsParams struct { type GetEventsWithSettingsParams struct {
@ -235,6 +242,7 @@ type GetEventsWithSettingsParams struct {
FirstStartTime pgtype.Timestamp `json:"first_start_time"` FirstStartTime pgtype.Timestamp `json:"first_start_time"`
CountryCode pgtype.Text `json:"country_code"` CountryCode pgtype.Text `json:"country_code"`
IsFeatured pgtype.Bool `json:"is_featured"` IsFeatured pgtype.Bool `json:"is_featured"`
IsActive pgtype.Bool `json:"is_active"`
Offset pgtype.Int4 `json:"offset"` Offset pgtype.Int4 `json:"offset"`
Limit pgtype.Int4 `json:"limit"` Limit pgtype.Int4 `json:"limit"`
} }
@ -283,6 +291,7 @@ func (q *Queries) GetEventsWithSettings(ctx context.Context, arg GetEventsWithSe
arg.FirstStartTime, arg.FirstStartTime,
arg.CountryCode, arg.CountryCode,
arg.IsFeatured, arg.IsFeatured,
arg.IsActive,
arg.Offset, arg.Offset,
arg.Limit, arg.Limit,
) )
@ -531,8 +540,14 @@ WHERE is_live = false
) )
AND ( AND (
ces.is_featured = $8 ces.is_featured = $8
OR e.default_is_featured = $8
OR $8 IS NULL OR $8 IS NULL
) )
AND (
ces.is_active = $9
OR e.default_is_active = $9
OR $9 IS NULL
)
` `
type GetTotalCompanyEventsParams struct { type GetTotalCompanyEventsParams struct {
@ -544,6 +559,7 @@ type GetTotalCompanyEventsParams struct {
FirstStartTime pgtype.Timestamp `json:"first_start_time"` FirstStartTime pgtype.Timestamp `json:"first_start_time"`
CountryCode pgtype.Text `json:"country_code"` CountryCode pgtype.Text `json:"country_code"`
IsFeatured pgtype.Bool `json:"is_featured"` IsFeatured pgtype.Bool `json:"is_featured"`
IsActive pgtype.Bool `json:"is_active"`
} }
func (q *Queries) GetTotalCompanyEvents(ctx context.Context, arg GetTotalCompanyEventsParams) (int64, error) { 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.FirstStartTime,
arg.CountryCode, arg.CountryCode,
arg.IsFeatured, arg.IsFeatured,
arg.IsActive,
) )
var count int64 var count int64
err := row.Scan(&count) err := row.Scan(&count)

View File

@ -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, COALESCE(cls.is_featured, l.default_is_featured) AS is_featured,
cls.updated_at cls.updated_at
FROM leagues l 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 ( WHERE (
country_code = $2 country_code = $2
OR $2 IS NULL OR $2 IS NULL
@ -113,10 +114,12 @@ WHERE (
) )
AND ( AND (
is_active = $4 is_active = $4
OR default_is_active = $4
OR $4 IS NULL OR $4 IS NULL
) )
AND ( AND (
is_featured = $5 is_featured = $5
OR default_is_featured = $5
OR $5 IS NULL OR $5 IS NULL
) )
AND ( AND (
@ -196,6 +199,58 @@ func (q *Queries) GetAllLeaguesWithSettings(ctx context.Context, arg GetAllLeagu
return items, nil 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 const InsertLeague = `-- name: InsertLeague :exec
INSERT INTO leagues ( INSERT INTO leagues (
id, id,

View File

@ -502,6 +502,14 @@ type RaffleTicket struct {
IsActive pgtype.Bool `json:"is_active"` 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 { type ReferralCode struct {
ID int64 `json:"id"` ID int64 `json:"id"`
ReferralCode string `json:"referral_code"` ReferralCode string `json:"referral_code"`
@ -514,14 +522,6 @@ type ReferralCode struct {
UpdatedAt pgtype.Timestamptz `json:"updated_at"` 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 { type RefreshToken struct {
ID int64 `json:"id"` ID int64 `json:"id"`
UserID int64 `json:"user_id"` UserID int64 `json:"user_id"`

View File

@ -219,6 +219,7 @@ type EventFilter struct {
Offset ValidInt32 Offset ValidInt32
MatchStatus ValidString // e.g., "upcoming", "in_play", "ended" MatchStatus ValidString // e.g., "upcoming", "in_play", "ended"
Featured ValidBool Featured ValidBool
Active ValidBool
} }
func ConvertDBEvent(event dbgen.EventWithCountry) BaseEvent { func ConvertDBEvent(event dbgen.EventWithCountry) BaseEvent {

View File

@ -144,7 +144,7 @@ func ConvertDBBaseLeagues(leagues []dbgen.League) []BaseLeague {
return result return result
} }
func ConvertDBLeagueWithSetting(lws dbgen.LeagueWithSetting) LeagueWithSettings { func ConvertDBLeagueWithSetting(lws dbgen.GetAllLeaguesWithSettingsRow) LeagueWithSettings {
return LeagueWithSettings{ return LeagueWithSettings{
ID: lws.ID, ID: lws.ID,
Name: lws.Name, 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)) result := make([]LeagueWithSettings, len(lws))
for i, league := range lws { for i, league := range lws {
result[i] = ConvertDBLeagueWithSetting(league) result[i] = ConvertDBLeagueWithSetting(league)

View File

@ -86,6 +86,7 @@ func (s *Store) GetEventsWithSettings(ctx context.Context, companyID int64, filt
LastStartTime: filter.LastStartTime.ToPG(), LastStartTime: filter.LastStartTime.ToPG(),
CountryCode: filter.CountryCode.ToPG(), CountryCode: filter.CountryCode.ToPG(),
IsFeatured: filter.Featured.ToPG(), IsFeatured: filter.Featured.ToPG(),
IsActive: filter.Active.ToPG(),
}) })
if err != nil { if err != nil {
@ -101,6 +102,7 @@ func (s *Store) GetEventsWithSettings(ctx context.Context, companyID int64, filt
LastStartTime: filter.LastStartTime.ToPG(), LastStartTime: filter.LastStartTime.ToPG(),
CountryCode: filter.CountryCode.ToPG(), CountryCode: filter.CountryCode.ToPG(),
IsFeatured: filter.Featured.ToPG(), IsFeatured: filter.Featured.ToPG(),
IsActive: filter.Active.ToPG(),
}) })
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err

View File

@ -37,7 +37,8 @@ func (s *Store) GetAllLeagues(ctx context.Context, filter domain.LeagueFilter) (
return domain.ConvertDBBaseLeagues(l), nil 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{ l, err := s.queries.GetAllLeaguesWithSettings(ctx, dbgen.GetAllLeaguesWithSettingsParams{
Query: filter.Query.ToPG(), Query: filter.Query.ToPG(),
CompanyID: companyID, CompanyID: companyID,
@ -52,38 +53,26 @@ func (s *Store) GetAllLeaguesByCompany(ctx context.Context, companyID int64, fil
Valid: filter.Offset.Valid, Valid: filter.Offset.Valid,
}, },
IsFeatured: filter.IsFeatured.ToPG(), IsFeatured: filter.IsFeatured.ToPG(),
IsActive: filter.IsActive.ToPG(), IsActive: filter.IsActive.ToPG(),
}) })
if err != nil { if err != nil {
return nil, err return nil, 0, err
} }
result := make([]domain.LeagueWithSettings, len(l)) total, err := s.queries.GetTotalLeaguesWithSettings(ctx, dbgen.GetTotalLeaguesWithSettingsParams{
for i, league := range l { Query: filter.Query.ToPG(),
result[i] = domain.LeagueWithSettings{ CompanyID: companyID,
ID: league.ID, CountryCode: filter.CountryCode.ToPG(),
Name: league.Name, SportID: filter.SportID.ToPG(),
CompanyID: league.CompanyID.Int64, IsFeatured: filter.IsFeatured.ToPG(),
CountryCode: domain.ValidString{ IsActive: filter.IsActive.ToPG(),
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,
DefaultIsActive: league.DefaultIsActive, if err != nil {
DefaultIsFeatured: league.DefaultIsFeatured, return nil, 0, err
}
} }
return domain.ConvertDBLeagueWithSettings(l), total, nil
return result, nil
} }
func (s *Store) CheckLeagueSupport(ctx context.Context, leagueID int64, companyID int64) (bool, error) { func (s *Store) CheckLeagueSupport(ctx context.Context, leagueID int64, companyID int64) (bool, error) {

View File

@ -10,7 +10,7 @@ type Service interface {
SaveLeague(ctx context.Context, league domain.CreateLeague) error SaveLeague(ctx context.Context, league domain.CreateLeague) error
SaveLeagueSettings(ctx context.Context, leagueSettings domain.CreateLeagueSettings) error SaveLeagueSettings(ctx context.Context, leagueSettings domain.CreateLeagueSettings) error
GetAllLeagues(ctx context.Context, filter domain.LeagueFilter) ([]domain.BaseLeague, 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) CheckLeagueSupport(ctx context.Context, leagueID int64, companyID int64) (bool, error)
UpdateLeague(ctx context.Context, league domain.UpdateLeague) error UpdateLeague(ctx context.Context, league domain.UpdateLeague) error
} }

View File

@ -29,7 +29,7 @@ func (s *service) GetAllLeagues(ctx context.Context, filter domain.LeagueFilter)
return s.store.GetAllLeagues(ctx, filter) 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) return s.store.GetAllLeaguesByCompany(ctx, companyID, filter)
} }

View File

@ -26,71 +26,71 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S
spec string spec string
task func() task func()
}{ }{
{ // {
spec: "0 0 * * * *", // Every 1 hour // spec: "0 0 * * * *", // Every 1 hour
task: func() { // task: func() {
mongoLogger.Info("Began fetching upcoming events cron task") // mongoLogger.Info("Began fetching upcoming events cron task")
if err := eventService.FetchUpcomingEvents(context.Background()); err != nil { // if err := eventService.FetchUpcomingEvents(context.Background()); err != nil {
mongoLogger.Error("Failed to fetch upcoming events", // mongoLogger.Error("Failed to fetch upcoming events",
zap.Error(err), // zap.Error(err),
) // )
} else { // } else {
mongoLogger.Info("Completed fetching upcoming events without errors") // mongoLogger.Info("Completed fetching upcoming events without errors")
} // }
}, // },
}, // },
{ // {
spec: "0 0 * * * *", // Every 1 hour (since its takes that long to fetch all the events) // spec: "0 0 * * * *", // Every 1 hour (since its takes that long to fetch all the events)
task: func() { // task: func() {
mongoLogger.Info("Began fetching non live odds cron task") // mongoLogger.Info("Began fetching non live odds cron task")
if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil { // if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
mongoLogger.Error("Failed to fetch non live odds", // mongoLogger.Error("Failed to fetch non live odds",
zap.Error(err), // zap.Error(err),
) // )
} else { // } else {
mongoLogger.Info("Completed fetching non live odds without errors") // mongoLogger.Info("Completed fetching non live odds without errors")
} // }
}, // },
}, // },
{ // {
spec: "0 */5 * * * *", // Every 5 Minutes // spec: "0 */5 * * * *", // Every 5 Minutes
task: func() { // task: func() {
mongoLogger.Info("Began update all expired events status cron task") // mongoLogger.Info("Began update all expired events status cron task")
if _, err := resultService.CheckAndUpdateExpiredEvents(context.Background()); err != nil { // if _, err := resultService.CheckAndUpdateExpiredEvents(context.Background()); err != nil {
mongoLogger.Error("Failed to update expired events status", // mongoLogger.Error("Failed to update expired events status",
zap.Error(err), // zap.Error(err),
) // )
} else { // } else {
mongoLogger.Info("Completed expired events without errors") // mongoLogger.Info("Completed expired events without errors")
} // }
}, // },
}, // },
{ // {
spec: "0 */15 * * * *", // Every 15 Minutes // spec: "0 */15 * * * *", // Every 15 Minutes
task: func() { // task: func() {
mongoLogger.Info("Began fetching results for upcoming events cron task") // mongoLogger.Info("Began fetching results for upcoming events cron task")
if err := resultService.FetchAndProcessResults(context.Background()); err != nil { // if err := resultService.FetchAndProcessResults(context.Background()); err != nil {
mongoLogger.Error("Failed to process result", // mongoLogger.Error("Failed to process result",
zap.Error(err), // zap.Error(err),
) // )
} else { // } else {
mongoLogger.Info("Completed processing all event result outcomes without errors") // mongoLogger.Info("Completed processing all event result outcomes without errors")
} // }
}, // },
}, // },
{ // {
spec: "0 0 0 * * *", // Every Day // spec: "0 0 0 * * *", // Every Day
task: func() { // task: func() {
mongoLogger.Info("Began Send daily result notification cron task") // mongoLogger.Info("Began Send daily result notification cron task")
if err := resultService.CheckAndSendResultNotifications(context.Background(), time.Now().Add(-24*time.Hour)); err != nil { // if err := resultService.CheckAndSendResultNotifications(context.Background(), time.Now().Add(-24*time.Hour)); err != nil {
mongoLogger.Error("Failed to process result", // mongoLogger.Error("Failed to process result",
zap.Error(err), // zap.Error(err),
) // )
} else { // } else {
mongoLogger.Info("Completed sending daily result notification without errors") // mongoLogger.Info("Completed sending daily result notification without errors")
} // }
}, // },
}, // },
} }
for _, job := range schedule { for _, job := range schedule {

View File

@ -303,6 +303,7 @@ func (h *Handler) GetTenantUpcomingEvents(c *fiber.Ctx) error {
Offset: offset, Offset: offset,
CountryCode: countryCode, CountryCode: countryCode,
Featured: isFeatured, Featured: isFeatured,
Active: domain.ValidBool{Value: true, Valid: true},
}) })
// fmt.Printf("League ID: %v", leagueID) // 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") 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{ IsFeatured: domain.ValidBool{
Value: true, Value: true,
Valid: true, Valid: true,
}, },
}) })
if err != nil { if err != nil {
@ -371,6 +371,7 @@ func (h *Handler) GetTopLeagues(c *fiber.Ctx) error {
Value: league.ID, Value: league.ID,
Valid: true, Valid: true,
}, },
Active: domain.ValidBool{Value: true, Valid: true},
}) })
if err != nil { if err != nil {
h.InternalServerErrorLogger().Warn("Error while fetching events for top league", h.InternalServerErrorLogger().Warn("Error while fetching events for top league",
@ -570,7 +571,6 @@ type SetEventIsMonitoredReq struct {
IsMonitored bool `json:"is_monitored"` IsMonitored bool `json:"is_monitored"`
} }
// SetEventIsMonitored godoc // SetEventIsMonitored godoc
// @Summary update the event is_monitored // @Summary update the event is_monitored
// @Description Update the event is_monitored // @Description Update the event is_monitored

View File

@ -189,7 +189,7 @@ func (h *Handler) GetAllLeaguesForTenant(c *fiber.Ctx) error {
zap.Bool("sport_id_valid", sportID.Valid), 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, CountryCode: countryCode,
IsActive: isActive, IsActive: isActive,
SportID: sportID, SportID: sportID,
@ -206,7 +206,7 @@ func (h *Handler) GetAllLeaguesForTenant(c *fiber.Ctx) error {
res := domain.ConvertLeagueWithSettingResList(leagues) 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 { type SetLeagueActiveReq struct {