From c416819f0a924bfa0b17d41c34c4f11bf3d6fbb8 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 4 Sep 2024 12:18:06 +0530 Subject: [PATCH 1/2] [server] Increase duration of free trial --- server/ente/billing.go | 4 ++-- server/pkg/utils/billing/billing.go | 2 +- server/pkg/utils/time/time.go | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/ente/billing.go b/server/ente/billing.go index 111d0847e7..0aa8faf2c4 100644 --- a/server/ente/billing.go +++ b/server/ente/billing.go @@ -16,8 +16,8 @@ const ( FreePlanProductID = "free" // FreePlanTransactionID is the dummy transaction ID for the free plan FreePlanTransactionID = "none" - // TrialPeriodDuration is the duration of the free trial - TrialPeriodDuration = 365 + // TrialPeriodDuration is the duration (in years) of the free trial + TrialPeriodDuration = 100 // TrialPeriod is the unit for the duration of the free trial TrialPeriod = "days" diff --git a/server/pkg/utils/billing/billing.go b/server/pkg/utils/billing/billing.go index d5f5f57057..e6e0e6a718 100644 --- a/server/pkg/utils/billing/billing.go +++ b/server/pkg/utils/billing/billing.go @@ -108,7 +108,7 @@ func GetFreeSubscription(userID int64) ente.Subscription { ProductID: ente.FreePlanProductID, OriginalTransactionID: ente.FreePlanTransactionID, Storage: ente.FreePlanStorage, - ExpiryTime: time.NDaysFromNow(ente.TrialPeriodDuration), + ExpiryTime: time.NYearsFromNow(ente.TrialPeriodDuration), } } diff --git a/server/pkg/utils/time/time.go b/server/pkg/utils/time/time.go index a07df4b262..b4fda7f68b 100644 --- a/server/pkg/utils/time/time.go +++ b/server/pkg/utils/time/time.go @@ -48,6 +48,10 @@ func NDaysFromNow(n int) int64 { return time.Now().AddDate(0, 0, n).UnixNano() / 1000 } +func NYearsFromNow(n int) int64 { + return time.Now().AddDate(n, 0, 0).UnixNano() / 1000 +} + // NMinFromNow returns the time n min from now in micro seconds func NMinFromNow(n int64) int64 { return time.Now().Add(time.Minute*time.Duration(n)).UnixNano() / 1000 From 5cd37a02c7e07585c139e209588efc79e3781847 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:05:36 +0530 Subject: [PATCH 2/2] [server] Bump up expiry_time for free plan --- server/migrations/91_increase_free_validity.down.sql | 1 + server/migrations/91_increase_free_validity.up.sql | 1 + 2 files changed, 2 insertions(+) create mode 100644 server/migrations/91_increase_free_validity.down.sql create mode 100644 server/migrations/91_increase_free_validity.up.sql diff --git a/server/migrations/91_increase_free_validity.down.sql b/server/migrations/91_increase_free_validity.down.sql new file mode 100644 index 0000000000..f665f2cfe3 --- /dev/null +++ b/server/migrations/91_increase_free_validity.down.sql @@ -0,0 +1 @@ +-- no-op \ No newline at end of file diff --git a/server/migrations/91_increase_free_validity.up.sql b/server/migrations/91_increase_free_validity.up.sql new file mode 100644 index 0000000000..236bf4dbca --- /dev/null +++ b/server/migrations/91_increase_free_validity.up.sql @@ -0,0 +1 @@ +UPDATE subscriptions SET expiry_time = 4749355117000000 where storage = 5368709120 and product_id = 'free' and original_transaction_id ='none';