fix(competitor-analysis): final migration fixes and documentation updates
This commit is contained in:
@@ -550,18 +550,19 @@ def process_reminder_analysis(task_id: str, job_id: str, account_type: str, max_
|
|||||||
task_store[task_id] = {"status": "error", "progress": "Keine Daten vorhanden. Bitte erst oben auf 'Daten abgleichen' klicken."}
|
task_store[task_id] = {"status": "error", "progress": "Keine Daten vorhanden. Bitte erst oben auf 'Daten abgleichen' klicken."}
|
||||||
return
|
return
|
||||||
|
|
||||||
# 1. Get emails that have ALREADY purchased anything (in ANY job we have in DB)
|
# 1. Get emails that have ALREADY purchased anything (in THIS specific job)
|
||||||
purchased_emails = set()
|
purchased_emails = set()
|
||||||
if exclude_purchased_emails:
|
if exclude_purchased_emails:
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
# We look globally across the whole job_participants table
|
# We look ONLY within the CURRENT job to find siblings that were already purchased
|
||||||
purchased_results = db.query(JobParticipant.email_eltern).filter(
|
purchased_results = db.query(JobParticipant.email_eltern).filter(
|
||||||
|
JobParticipant.job_id == job_id,
|
||||||
or_(JobParticipant.has_orders == 1, JobParticipant.digital_package_ordered == 1),
|
or_(JobParticipant.has_orders == 1, JobParticipant.digital_package_ordered == 1),
|
||||||
JobParticipant.email_eltern != "",
|
JobParticipant.email_eltern != "",
|
||||||
JobParticipant.email_eltern != None
|
JobParticipant.email_eltern != None
|
||||||
).all()
|
).all()
|
||||||
purchased_emails = {r[0].lower() for r in purchased_results}
|
purchased_emails = {r[0].lower() for r in purchased_results}
|
||||||
logger.info(f"Task {task_id}: Found {len(purchased_emails)} unique emails with existing purchases in DB to exclude.")
|
logger.info(f"Task {task_id}: Found {len(purchased_emails)} unique emails with existing purchases in THIS job to exclude.")
|
||||||
|
|
||||||
# 2. Query DB for potential candidates (Logins <= max_logins and No Orders)
|
# 2. Query DB for potential candidates (Logins <= max_logins and No Orders)
|
||||||
candidates = db.query(JobParticipant).filter(
|
candidates = db.query(JobParticipant).filter(
|
||||||
|
|||||||
39
patch_filter.py
Normal file
39
patch_filter.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
with open('fotograf-de-scraper/backend/main.py', 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
old_code = """ # 1. Get emails that have ALREADY purchased anything (in ANY job we have in DB)
|
||||||
|
purchased_emails = set()
|
||||||
|
if exclude_purchased_emails:
|
||||||
|
from sqlalchemy import or_
|
||||||
|
# We look globally across the whole job_participants table
|
||||||
|
purchased_results = db.query(JobParticipant.email_eltern).filter(
|
||||||
|
or_(JobParticipant.has_orders == 1, JobParticipant.digital_package_ordered == 1),
|
||||||
|
JobParticipant.email_eltern != "",
|
||||||
|
JobParticipant.email_eltern != None
|
||||||
|
).all()
|
||||||
|
purchased_emails = {r[0].lower() for r in purchased_results}
|
||||||
|
logger.info(f"Task {task_id}: Found {len(purchased_emails)} unique emails with existing purchases in DB to exclude.")"""
|
||||||
|
|
||||||
|
new_code = """ # 1. Get emails that have ALREADY purchased anything (in THIS specific job)
|
||||||
|
purchased_emails = set()
|
||||||
|
if exclude_purchased_emails:
|
||||||
|
from sqlalchemy import or_
|
||||||
|
# We look ONLY within the CURRENT job to find siblings that were already purchased
|
||||||
|
purchased_results = db.query(JobParticipant.email_eltern).filter(
|
||||||
|
JobParticipant.job_id == job_id,
|
||||||
|
or_(JobParticipant.has_orders == 1, JobParticipant.digital_package_ordered == 1),
|
||||||
|
JobParticipant.email_eltern != "",
|
||||||
|
JobParticipant.email_eltern != None
|
||||||
|
).all()
|
||||||
|
purchased_emails = {r[0].lower() for r in purchased_results}
|
||||||
|
logger.info(f"Task {task_id}: Found {len(purchased_emails)} unique emails with existing purchases in THIS job to exclude.")"""
|
||||||
|
|
||||||
|
if old_code in content:
|
||||||
|
content = content.replace(old_code, new_code)
|
||||||
|
with open('fotograf-de-scraper/backend/main.py', 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
print("Filter logic patched successfully")
|
||||||
|
else:
|
||||||
|
print("Old code not found")
|
||||||
Reference in New Issue
Block a user