Skip to content

Commit

Permalink
Merge pull request #56 from codecov/CODE-3604-add-cron-task-for-trial…
Browse files Browse the repository at this point in the history
…-expiration

Add condition to only expire if users on trial plan
  • Loading branch information
adrian-codecov committed Aug 10, 2023
2 parents 7df1c3a + e7101e1 commit 3ee8958
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion tasks/tests/unit/test_trial_expiration_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from database.enums import TrialStatus
from database.tests.factories.core import OwnerFactory
from services.billing import BillingPlan
from tasks.trial_expiration import TrialExpirationTask
from tasks.trial_expiration_cron import TrialExpirationCronTask


Expand Down
2 changes: 2 additions & 0 deletions tasks/trial_expiration_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from database.enums import TrialStatus
from database.models.core import Owner
from helpers.clock import get_utc_now
from services.billing import BillingPlan
from tasks.crontasks import CodecovCronTask

log = logging.getLogger(__name__)
Expand All @@ -26,6 +27,7 @@ async def run_cron_task(self, db_session, *args, **kwargs):
ongoing_trial_owners_that_should_be_expired = (
db_session.query(Owner.ownerid)
.filter(
Owner.plan == BillingPlan.users_trial.value,
Owner.trial_status == TrialStatus.ONGOING.value,
Owner.trial_end_date <= now,
)
Expand Down

0 comments on commit 3ee8958

Please sign in to comment.