fix(audit): Fix false photo/logo detection in GBP audits
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

- Replace hardcoded logo_present=False with heuristic (photo_count>=1)
- Replace hardcoded cover_photo_present=False with heuristic (>=2)
- Fix has_photos to use photo_count>0 instead of score threshold
- Add descriptive photo_status string for AI context
- Add UWAGA section in Gemini prompt for cautious recommendations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-02-08 10:36:15 +01:00
parent 706dcfd680
commit 09ae03dcec
2 changed files with 23 additions and 6 deletions

View File

@ -134,6 +134,19 @@ def _collect_gbp_data(db, company) -> dict:
if not audit:
return {}
# Build descriptive photo status for AI context
photo_count = audit.photo_count or 0
if photo_count == 0:
photo_status = "Brak zdjęć w profilu"
elif photo_count == 1:
photo_status = "1 zdjęcie (prawdopodobnie logo)"
elif photo_count == 2:
photo_status = f"2 zdjęcia (prawdopodobnie logo i zdjęcie w tle)"
elif photo_count < 10:
photo_status = f"{photo_count} zdjęć (logo i zdjęcie w tle prawdopodobnie ustawione, ale mało zdjęć dodatkowych)"
else:
photo_status = f"{photo_count} zdjęć (dobra ilość)"
return {
'company_name': company.name,
'company_category': company.category.name if company.category else None,
@ -162,9 +175,10 @@ def _collect_gbp_data(db, company) -> dict:
'has_products': audit.has_products,
'has_qa': audit.has_qa,
# Photos
'photo_count': audit.photo_count,
'photo_count': photo_count,
'logo_present': audit.logo_present,
'cover_photo_present': audit.cover_photo_present,
'photo_status': photo_status,
# NAP
'nap_consistent': audit.nap_consistent,
'nap_issues': audit.nap_issues,
@ -311,8 +325,11 @@ WYNIKI AUDYTU GBP (kompletność: {data.get('completeness_score', 'brak')}/100):
- Zdjęcia: {'' if data.get('has_photos') else ''} ({data.get('photo_count', 0)} zdjęć)
- Opis: {'' if data.get('has_description') else ''}
- Usługi: {'' if data.get('has_services') else ''}
- Logo: {'' if data.get('logo_present') else ''}
- Zdjęcie w tle: {'' if data.get('cover_photo_present') else ''}
- Logo: {'✓ (wykryte heurystycznie)' if data.get('logo_present') else ''}
- Zdjęcie w tle: {'✓ (wykryte heurystycznie)' if data.get('cover_photo_present') else ''}
- Status zdjęć: {data.get('photo_status', 'brak danych')}
UWAGA: Logo i zdjęcie w tle wykrywane heurystycznie na podstawie liczby zdjęć (1+ = logo, 2+ = cover). Nie traktuj tego jako pewnik - formułuj rekomendacje dot. zdjęć ostrożnie, np. "sprawdź czy logo jest ustawione" zamiast "BRAKUJE logo".
Opinie:
- Liczba opinii: {data.get('review_count', 0)}

View File

@ -459,8 +459,8 @@ class GBPAuditService:
fields=fields,
recommendations=recommendations,
photo_count=fields['photos'].value if isinstance(fields['photos'].value, int) else 0,
logo_present=False, # Would need specific logo detection
cover_photo_present=False, # Would need specific cover detection
logo_present=(fields['photos'].value or 0) >= 1 if isinstance(fields['photos'].value, int) else False,
cover_photo_present=(fields['photos'].value or 0) >= 2 if isinstance(fields['photos'].value, int) else False,
review_count=review_count,
average_rating=average_rating,
google_place_id=google_place_id,
@ -515,7 +515,7 @@ class GBPAuditService:
has_website=result.fields.get('website', FieldStatus('website', 'missing')).status == 'complete',
has_hours=result.fields.get('hours', FieldStatus('hours', 'missing')).status == 'complete',
has_categories=result.fields.get('categories', FieldStatus('categories', 'missing')).status == 'complete',
has_photos=result.fields.get('photos', FieldStatus('photos', 'missing')).status in ['complete', 'partial'],
has_photos=result.photo_count > 0,
has_description=result.fields.get('description', FieldStatus('description', 'missing')).status == 'complete',
has_services=result.fields.get('services', FieldStatus('services', 'missing')).status == 'complete',
has_reviews=result.fields.get('reviews', FieldStatus('reviews', 'missing')).status in ['complete', 'partial'],