From 814c6a8da476d8cda2efd8a74d2dc1ca46daac15 Mon Sep 17 00:00:00 2001 From: Indra Pramana Date: Sat, 19 Oct 2024 08:09:24 +0700 Subject: [PATCH] add new --- cmd/publisher.go | 8 ++++---- cmd/root.go | 1 + internal/domain/repository/schedule_repository.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/publisher.go b/cmd/publisher.go index 00ceb93..6af7833 100644 --- a/cmd/publisher.go +++ b/cmd/publisher.go @@ -389,11 +389,11 @@ var publisherScrapingPredictionCmd = &cobra.Command{ scheduleRepo := repository.NewScheduleRepository(db) scheduleService := services.NewScheduleService(scheduleRepo) - if scheduleService.IsUnlocked(ACT_SCRAPING, timeNow) { + if scheduleService.IsUnlocked(ACT_PREDICTION, timeNow) { scheduleService.UpdateLocked( &entity.Schedule{ - Name: ACT_SCRAPING, + Name: ACT_PREDICTION, }, ) @@ -402,10 +402,10 @@ var publisherScrapingPredictionCmd = &cobra.Command{ }() } - if scheduleService.IsUnlocked(ACT_SCRAPING, timeNow) { + if scheduleService.IsUnlocked(ACT_PREDICTION, timeNow) { scheduleService.Update( &entity.Schedule{ - Name: ACT_SCRAPING, + Name: ACT_PREDICTION, IsUnlocked: true, }, ) diff --git a/cmd/root.go b/cmd/root.go index 46dede7..c628ce8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -78,6 +78,7 @@ const ( ACT_SUB string = "SUB" ACT_UNSUB string = "UNSUB" ACT_USER_LOSES string = "USER_LOSES" + ACT_PREDICTION string = "PREDICTION" ACT_SCRAPING string = "SCRAPING" ) diff --git a/internal/domain/repository/schedule_repository.go b/internal/domain/repository/schedule_repository.go index 74d4b36..e89b4bb 100644 --- a/internal/domain/repository/schedule_repository.go +++ b/internal/domain/repository/schedule_repository.go @@ -79,7 +79,7 @@ func (r *ScheduleRepository) Update(c *entity.Schedule) error { } func (r *ScheduleRepository) UpdateLocked(c *entity.Schedule) error { - err := r.db.Where("name = ?", c.Name).Update("is_unlocked", false).Error + err := r.db.Model(c).Where("name = ?", c.Name).Update("is_unlocked", false).Error if err != nil { return err }