From c5481fd46c0be48c07c4ead0b3fdace89629520e Mon Sep 17 00:00:00 2001 From: Indra Pramana Date: Sat, 12 Oct 2024 16:26:23 +0700 Subject: [PATCH] add new --- internal/domain/repository/subscription_respository.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/domain/repository/subscription_respository.go b/internal/domain/repository/subscription_respository.go index 091ede6..08f3aa6 100644 --- a/internal/domain/repository/subscription_respository.go +++ b/internal/domain/repository/subscription_respository.go @@ -200,7 +200,7 @@ func (r *SubscriptionRepository) Prediction() (*[]entity.Subscription, error) { // SELECT (UNIX_TIMESTAMP("2017-06-10 18:30:10")-UNIX_TIMESTAMP("2017-06-10 18:40:10"))/3600 hour_diff func (r *SubscriptionRepository) Renewal() (*[]entity.Subscription, error) { var sub []entity.Subscription - err := r.db.Where(&entity.Subscription{IsActive: true}).Where("UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(renewal_at) / 3600 > 0").Order("DATE(created_at) DESC").Find(&sub).Error + err := r.db.Where(&entity.Subscription{IsActive: true}).Where("(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(renewal_at)) / 3600 > 0").Order("DATE(created_at) DESC").Find(&sub).Error if err != nil { return nil, err } @@ -210,7 +210,7 @@ func (r *SubscriptionRepository) Renewal() (*[]entity.Subscription, error) { // SELECT (UNIX_TIMESTAMP("2017-06-10 18:30:10" + INTERVAL 1 DAY)-UNIX_TIMESTAMP("2017-06-10 18:40:10"))/3600 hour_diff (tommorow) func (r *SubscriptionRepository) Retry() (*[]entity.Subscription, error) { var sub []entity.Subscription - err := r.db.Where(&entity.Subscription{IsRetry: true, IsActive: true}).Where("UNIX_TIMESTAMP(NOW() + INTERVAL 1 DAY) - UNIX_TIMESTAMP(renewal_at) / 3600 > 0").Order("DATE(created_at) DESC").Find(&sub).Error + err := r.db.Where(&entity.Subscription{IsRetry: true, IsActive: true}).Where("(UNIX_TIMESTAMP(NOW() + INTERVAL 1 DAY) - UNIX_TIMESTAMP(renewal_at)) / 3600 > 0").Order("DATE(created_at) DESC").Find(&sub).Error if err != nil { return nil, err }