Add lifetime case to events

This commit is contained in:
Adrià Casajús 2024-11-05 11:53:35 +01:00
parent 17c0af33e4
commit 18a299f1d2
No known key found for this signature in database
GPG key ID: F0033226A5AFC9B9

View file

@ -2,6 +2,7 @@
import argparse import argparse
import time import time
import arrow
from sqlalchemy import func from sqlalchemy import func
from app.events.event_dispatcher import EventDispatcher from app.events.event_dispatcher import EventDispatcher
@ -30,6 +31,7 @@ step = 100
updated = 0 updated = 0
start_time = time.time() start_time = time.time()
with_premium = 0 with_premium = 0
with_lifetime = 0
for batch_start in range(pu_id_start, max_pu_id, step): for batch_start in range(pu_id_start, max_pu_id, step):
partner_users = ( partner_users = (
Session.query(PartnerUser).filter( Session.query(PartnerUser).filter(
@ -41,7 +43,10 @@ for batch_start in range(pu_id_start, max_pu_id, step):
include_partner_subscription=False include_partner_subscription=False
) )
end_timestamp = None 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 with_premium += 1
end_timestamp = subscription_end.timestamp end_timestamp = subscription_end.timestamp
event = UserPlanChanged(plan_end_time=end_timestamp) event = UserPlanChanged(plan_end_time=end_timestamp)
@ -60,4 +65,4 @@ for batch_start in range(pu_id_start, max_pu_id, step):
print( print(
f"\PartnerUser {batch_start}/{max_pu_id} {updated} {hours_remaining:.2f} mins remaining" 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}")