From b0befd2973ff80fbd216f9cba5619da7a39e0ccc Mon Sep 17 00:00:00 2001 From: Maciej Pienczyn Date: Sat, 21 Feb 2026 16:09:54 +0100 Subject: [PATCH] fix: correct links_without_text count and add overall score calculation 1. seo_analyzer.py: Consider aria-label, title, img AND svg as valid link text (SVG icon links were falsely counted as "without text") 2. routes_portal_seo.py: Calculate overall_seo score using SEOAuditor._calculate_overall_score() before saving to DB (was always None because stream route bypasses audit_company()) Co-Authored-By: Claude Opus 4.6 --- blueprints/admin/routes_portal_seo.py | 7 +++++++ scripts/seo_analyzer.py | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/blueprints/admin/routes_portal_seo.py b/blueprints/admin/routes_portal_seo.py index 55b6739..6ff1b8e 100644 --- a/blueprints/admin/routes_portal_seo.py +++ b/blueprints/admin/routes_portal_seo.py @@ -489,6 +489,13 @@ def admin_portal_seo_run_stream(): 'status': 'error' }) + # Calculate overall score (same algorithm as SEOAuditor) + try: + overall = auditor._calculate_overall_score(result) + result['scores']['overall_seo'] = overall + except Exception: + pass + # Step 9: Save to DB yield _sse_event({ 'step': 9, 'total': TOTAL, diff --git a/scripts/seo_analyzer.py b/scripts/seo_analyzer.py index 6de4c62..ab05633 100644 --- a/scripts/seo_analyzer.py +++ b/scripts/seo_analyzer.py @@ -579,8 +579,15 @@ class OnPageSEOAnalyzer: result.broken_anchor_links += 1 continue - # Check for links without text - if not text and not anchor.find('img'): + # Check for links without text (consider aria-label, title, img, svg) + has_accessible_text = bool( + text + or anchor.get('aria-label') + or anchor.get('title') + or anchor.find('img') + or anchor.find('svg') + ) + if not has_accessible_text: result.links_without_text += 1 # Check for nofollow