fix(competitor-analysis): final migration fixes and documentation updates

This commit is contained in:
2026-05-15 20:07:45 +00:00
parent efdd134556
commit 6e1a3be8cf
4 changed files with 160 additions and 53 deletions

View File

@@ -585,6 +585,8 @@ def process_reminder_analysis(task_id: str, job_id: str, account_type: str, max_
aggregation = {}
missing_links_count = 0
base_url = "https://kinderfoto-erding.fotograf.de" if account_type == "kiga" else "https://kinderfotos-erding.fotograf.de"
for c in candidates:
email = c.email_eltern.lower()
@@ -592,12 +594,6 @@ def process_reminder_analysis(task_id: str, job_id: str, account_type: str, max_
if exclude_purchased_emails and email in purchased_emails:
continue
# STRICT LINK CHECK: If we don't have a scraped Quick Login URL, skip this child.
# We don't want to send broken /login/access/ links.
if not c.quick_login_url:
missing_links_count += 1
continue
if email not in aggregation:
aggregation[email] = {
"email": email,
@@ -612,8 +608,18 @@ def process_reminder_analysis(task_id: str, job_id: str, account_type: str, max_
if child_label and child_label not in aggregation[email]["children"]:
aggregation[email]["children"].append(child_label)
# Add Quick Login Link (Guaranteed to exist here)
html_link = f'<a href="{c.quick_login_url}">Fotos von {child_label}</a>'
# Determine best link
if c.quick_login_url and "/gc/" in c.quick_login_url:
# Use scraped direct link if available
final_link = c.quick_login_url
link_text = f"Fotos von {child_label}"
else:
# Fallback to direct code navigation link
final_link = f"{base_url}/login/{c.zugangscode}"
link_text = f"Fotos von {child_label}"
missing_links_count += 1
html_link = f'<a href="{final_link}">{link_text}</a>'
if html_link not in aggregation[email]["links"]:
aggregation[email]["links"].append(html_link)
@@ -633,7 +639,7 @@ def process_reminder_analysis(task_id: str, job_id: str, account_type: str, max_
progress_msg = f"Analyse fertig! {len(final_result)} Empfänger identifiziert."
if missing_links_count > 0:
progress_msg += f" (Hinweis: {missing_links_count} Kinder ignoriert, da Quick-Login-Link fehlt. Bitte vorher 'Daten abgleichen' drücken!)"
progress_msg += f" (Hinweis: {missing_links_count} Links wurden generiert, da sie noch nicht gescraped wurden.)"
task_store[task_id] = {
"status": "completed",