Skip to content

Commit

Permalink
Add lifetime case to events
Browse files Browse the repository at this point in the history
  • Loading branch information
acasajus committed Nov 5, 2024
1 parent 17c0af3 commit 18a299f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions oneshot/send_plan_change_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse
import time

import arrow
from sqlalchemy import func

from app.events.event_dispatcher import EventDispatcher
Expand Down Expand Up @@ -30,6 +31,7 @@
updated = 0
start_time = time.time()
with_premium = 0
with_lifetime = 0
for batch_start in range(pu_id_start, max_pu_id, step):
partner_users = (
Session.query(PartnerUser).filter(
Expand All @@ -41,7 +43,10 @@
include_partner_subscription=False
)
end_timestamp = None
if subscription_end:
if partner_user.user.lifetime:
with_lifetime += 1
end_timestamp = arrow.get("2100-01-01")
elif subscription_end:
with_premium += 1
end_timestamp = subscription_end.timestamp
event = UserPlanChanged(plan_end_time=end_timestamp)
Expand All @@ -60,4 +65,4 @@
print(
f"\PartnerUser {batch_start}/{max_pu_id} {updated} {hours_remaining:.2f} mins remaining"
)
print(f"With SL premium {with_premium}")
print(f"With SL premium {with_premium} lifetime {with_lifetime}")

0 comments on commit 18a299f

Please sign in to comment.