Removed tblocker / Fixed trial subscriptions counting

This commit is contained in:
Capybara-z
2025-08-26 18:26:35 +03:00
parent 8e55225724
commit a54310da27
3 changed files with 8 additions and 136 deletions
+8 -4
View File
@@ -34,11 +34,15 @@ async def count_active_keys(session: AsyncSession) -> int:
async def count_trial_keys(session: AsyncSession) -> int:
subquery_success_payments = (
select(Payment.tg_id).where(and_(Payment.tg_id == Key.tg_id, Payment.status == "success")).exists()
trial_tariffs_subquery = (
select(Tariff.id).where(Tariff.group_code == "trial")
)
return await session.scalar(
select(func.count())
.select_from(Key)
.where(Key.tariff_id.in_(trial_tariffs_subquery))
)
return await session.scalar(select(func.count()).select_from(Key).where(not_(subquery_success_payments)))
async def get_tariff_distribution(