Skip to content

Commit

Permalink
add new
Browse files Browse the repository at this point in the history
  • Loading branch information
idprm committed Oct 30, 2024
1 parent 35bcec4 commit be8ff4f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/domain/entity/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,5 @@ func (s *Subscription) IsRenewal() bool {
}

func (e *Subscription) IsFirstFreeDay() bool {
return !e.IsFree
return e.CreatedAt.Format("2006-01-02") == time.Now().Format("2006-01-02")
}
6 changes: 3 additions & 3 deletions internal/domain/repository/team_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r *TeamRepository) CountByPrimaryId(primaryId int) (int64, error) {

func (r *TeamRepository) CountByName(name string) (int64, error) {
var count int64
err := r.db.Model(&entity.Team{}).Where("UPPER(name) LIKE UPPER(?) OR UPPER(code) LIKE UPPER(?) OR UPPER(keyword) LIKE UPPER(?)", "%"+name+"%", "%"+name+"%", "%"+name+"%").Count(&count).Error
err := r.db.Model(&entity.Team{}).Where("UPPER(name) LIKE UPPER(?) OR UPPER(code) LIKE UPPER(?) OR UPPER(keyword) LIKE UPPER(?) AND is_active = true", "%"+name+"%", "%"+name+"%", "%"+name+"%").Count(&count).Error
if err != nil {
return count, err
}
Expand All @@ -81,7 +81,7 @@ func (r *TeamRepository) CountLeagueByTeam(teamId int) (int64, error) {

func (r *TeamRepository) GetAllPaginate(p *entity.Pagination) (*entity.Pagination, error) {
var teams []*entity.Team
err := r.db.Where("UPPER(name) LIKE UPPER(?) OR UPPER(code) LIKE UPPER(?)", "%"+p.GetSearch()+"%", "%"+p.GetSearch()+"%").Scopes(Paginate(teams, p, r.db)).Find(&teams).Error
err := r.db.Where("UPPER(name) LIKE UPPER(?) OR UPPER(code) LIKE UPPER(?) AND is_active = true", "%"+p.GetSearch()+"%", "%"+p.GetSearch()+"%").Scopes(Paginate(teams, p, r.db)).Find(&teams).Error
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -118,7 +118,7 @@ func (r *TeamRepository) GetByPrimaryId(primaryId int) (*entity.Team, error) {

func (r *TeamRepository) GetByName(name string) (*entity.Team, error) {
var c entity.Team
err := r.db.Where("UPPER(name) LIKE UPPER(?) OR UPPER(code) LIKE UPPER(?) OR UPPER(keyword) LIKE UPPER(?)", "%"+name+"%", "%"+name+"%", "%"+name+"%").Take(&c).Error
err := r.db.Where("UPPER(name) LIKE UPPER(?) OR UPPER(code) LIKE UPPER(?) OR UPPER(keyword) LIKE UPPER(?) AND is_active = true", "%"+name+"%", "%"+name+"%", "%"+name+"%").Take(&c).Error
if err != nil {
return nil, err
}
Expand Down
24 changes: 24 additions & 0 deletions internal/handler/sms_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,30 @@ func (h *SMSHandler) AlreadySubAlerteCompetition(league *entity.League) {
log.Println(err.Error())
}

if !h.subscriptionFollowLeagueService.IsSub(sub.GetId(), league.GetId()) {
// insert follow league
h.subscriptionFollowLeagueService.Save(
&entity.SubscriptionFollowLeague{
SubscriptionID: sub.GetId(),
LeagueID: league.GetId(),
LimitPerDay: LIMIT_PER_DAY,
IsActive: true,
},
)
} else {
// update follow league
h.subscriptionFollowLeagueService.Update(
&entity.SubscriptionFollowLeague{
SubscriptionID: sub.GetId(),
LeagueID: league.GetId(),
LimitPerDay: LIMIT_PER_DAY,
IsActive: true,
},
)
}

//

mt := &model.MTRequest{
Smsc: h.req.GetTo(),
Keyword: h.req.GetSMS(),
Expand Down

0 comments on commit be8ff4f

Please sign in to comment.