Skip to content

Commit

Permalink
chore(api-gql): filter by enabled in timers reschedule
Browse files Browse the repository at this point in the history
  • Loading branch information
Satont committed Dec 17, 2024
1 parent 008b842 commit 6230a52
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions apps/api-gql/internal/services/admin-actions/admin-actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (c *Service) EventSubSubscribe(ctx context.Context, input EventSubSubscribe

func (c *Service) RescheduleTimers(ctx context.Context) error {
var entities []model.ChannelsTimers
if err := c.gorm.Find(&entities).Error; err != nil {
if err := c.gorm.Select("id", "enabled").Find(&entities).Error; err != nil {
return fmt.Errorf("failed to get timers: %w", err)
}

Expand All @@ -106,11 +106,14 @@ func (c *Service) RescheduleTimers(ctx context.Context) error {
},
)

c.twirbus.Timers.AddTimer.Publish(
timers.AddOrRemoveTimerRequest{
TimerID: timer.ID,
},
)
if timer.Enabled {
c.twirbus.Timers.AddTimer.Publish(
timers.AddOrRemoveTimerRequest{
TimerID: timer.ID,
},
)
}

}

return nil
Expand Down

0 comments on commit 6230a52

Please sign in to comment.