Improve cluster tariff error handling / Fix hot leads filtering logic

This commit is contained in:
Capybara-z
2025-07-11 14:15:04 +03:00
parent 68b9092749
commit 9427cb20d9
4 changed files with 93 additions and 3 deletions
+2
View File
@@ -18,6 +18,8 @@ async def get_hot_leads(session: AsyncSession):
select(Payment.tg_id)
.distinct()
.where(Payment.amount > 0)
.where(Payment.status == "success")
.where(Payment.payment_system.notin_(["referral", "coupon", "cashback"]))
.where(~Payment.tg_id.in_(subquery))
)
+2
View File
@@ -160,7 +160,9 @@ async def count_hot_leads(session: AsyncSession) -> int:
stmt = (
select(Payment.tg_id)
.where(Payment.amount > 0)
.where(Payment.status == "success")
.where(Payment.payment_system.notin_(["referral", "coupon", "cashback"]))
.where(not_(exists(subquery_active_keys.where(Key.tg_id == Payment.tg_id))))
.distinct()
)