Skip to content

Commit

Permalink
add new
Browse files Browse the repository at this point in the history
  • Loading branch information
idprm committed Dec 19, 2024
1 parent dab426b commit 21a0d86
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func routeUrlListener(db *gorm.DB, rds *redis.Client, rmq rmqp.AMQP, logger *log
livescoreRepo := repository.NewLiveScoreRepository(db)
livescoreService := services.NewLiveScoreService(livescoreRepo)

standingRepo := repository.NewStandingRepository(db)
standingService := services.NewStandingService(standingRepo)

predictionRepo := repository.NewPredictionRepository(db)
predictionService := services.NewPredictionService(predictionRepo)

Expand Down Expand Up @@ -239,6 +242,7 @@ func routeUrlListener(db *gorm.DB, rds *redis.Client, rmq rmqp.AMQP, logger *log
fixtureService,
livematchService,
livescoreService,
standingService,
predictionService,
newsService,
scheduleService,
Expand Down
4 changes: 4 additions & 0 deletions internal/domain/model/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ func (m *UssdRequest) IsLmLiveMatchLater() bool {
return m.GetSlug() == "lm-live-match-later"
}

func (m *UssdRequest) IsLmStanding() bool {
return m.GetSlug() == "lm-standing"
}

func (m *UssdRequest) IsLmSchedule() bool {
return m.GetSlug() == "lm-schedule"
}
Expand Down
10 changes: 10 additions & 0 deletions internal/domain/repository/league_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ILeagueRepository interface {
CountByName(string) (int64, error)
GetAllPaginate(*entity.Pagination) (*entity.Pagination, error)
GetAllByActive() ([]*entity.League, error)
GetAllUSSDByActive() ([]*entity.League, error)
GetOnlyWorldByActive() ([]*entity.League, error)
GetAllUSSD(int) ([]*entity.League, error)
GetAllEuropeUSSD(int) ([]*entity.League, error)
Expand Down Expand Up @@ -94,6 +95,15 @@ func (r *LeagueRepository) GetAllByActive() ([]*entity.League, error) {
return c, nil
}

func (r *LeagueRepository) GetAllUSSDByActive() ([]*entity.League, error) {
var c []*entity.League
err := r.db.Where("is_active = true AND sort <> 0").Where("country IN('England', 'Belgium', 'Portugal', 'France', 'Italy', 'Spain', 'Germany', 'World')").Find(&c).Error
if err != nil {
return nil, err
}
return c, nil
}

func (r *LeagueRepository) GetOnlyWorldByActive() ([]*entity.League, error) {
var c []*entity.League
err := r.db.Where(&entity.League{IsActive: true, Country: "World", Code: "UEFA"}).Find(&c).Error
Expand Down
11 changes: 11 additions & 0 deletions internal/handler/incoming_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type IncomingHandler struct {
fixtureService services.IFixtureService
livematchService services.ILiveMatchService
livescoreService services.ILiveScoreService
standingService services.IStandingService
predictionService services.IPredictionService
newsService services.INewsService
scheduleService services.IScheduleService
Expand All @@ -125,6 +126,7 @@ func NewIncomingHandler(
fixtureService services.IFixtureService,
livematchService services.ILiveMatchService,
livescoreService services.ILiveScoreService,
standingService services.IStandingService,
predictionService services.IPredictionService,
newsService services.INewsService,
scheduleService services.IScheduleService,
Expand All @@ -145,6 +147,7 @@ func NewIncomingHandler(
fixtureService: fixtureService,
livematchService: livematchService,
livescoreService: livescoreService,
standingService: standingService,
predictionService: predictionService,
newsService: newsService,
scheduleService: scheduleService,
Expand Down Expand Up @@ -378,6 +381,10 @@ func (h *IncomingHandler) Menu(c *fiber.Ctx) error {
data = h.LiveMatchesLater(c.BaseURL(), true, req.GetPage()+1)
}

if req.IsLmStanding() {

}

if req.IsLmSchedule() {
data = h.Schedules(c.BaseURL(), req.GetPage()+1)
}
Expand Down Expand Up @@ -949,6 +956,10 @@ func (h *IncomingHandler) LiveMatchesLater(baseUrl string, isActive bool, page i
return liveMatchsString
}

func (h *IncomingHandler) StandingByLeague(baseUrl string, page int) string {
return ""
}

func (h *IncomingHandler) Schedules(baseUrl string, page int) string {
schedules, err := h.fixtureService.GetAllScheduleUSSD(page)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/handler/scraper_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func (h *ScraperHandler) Predictions() {
func (h *ScraperHandler) Standings() {
fb := apifb.NewApiFb()

leagues, err := h.leagueService.GetOnlyWorldByActive()
leagues, err := h.leagueService.GetAllUSSDByActive()
if err != nil {
log.Println(err.Error())
}
Expand Down
5 changes: 5 additions & 0 deletions internal/services/league_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ILeagueService interface {
IsLeagueByName(string) bool
GetAllPaginate(*entity.Pagination) (*entity.Pagination, error)
GetAllByActive() ([]*entity.League, error)
GetAllUSSDByActive() ([]*entity.League, error)
GetOnlyWorldByActive() ([]*entity.League, error)
GetAllUSSD(int) ([]*entity.League, error)
GetAllEuropeUSSD(int) ([]*entity.League, error)
Expand Down Expand Up @@ -74,6 +75,10 @@ func (s *LeagueService) GetAllByActive() ([]*entity.League, error) {
return s.leagueRepo.GetAllByActive()
}

func (s *LeagueService) GetAllUSSDByActive() ([]*entity.League, error) {
return s.leagueRepo.GetAllUSSDByActive()
}

func (s *LeagueService) GetOnlyWorldByActive() ([]*entity.League, error) {
return s.leagueRepo.GetOnlyWorldByActive()
}
Expand Down

0 comments on commit 21a0d86

Please sign in to comment.