fix: GBP audit result is dataclass not dict, fix social count
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

- GBP: access .completeness_score attribute + call save_audit()
- Social: count saved DB records instead of parsing audit result dict

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-02-20 16:38:18 +01:00
parent 0e04a17785
commit 4daf43f9f7

View File

@ -184,9 +184,14 @@ def arm_company(company_id, force=False):
'address_city': company.address_city or '',
}
audit_result = auditor.audit_company(company_dict)
profiles = len(audit_result.get('social_media', {}).get('profiles', [])) if audit_result else 0
results['social'] = 'OK (%d profili)' % profiles
print(" -> OK: %d profili znalezionych" % profiles)
# Count profiles from social_media dict
sm = audit_result.get('social_media', {}) if audit_result else {}
profiles = len(sm.get('profiles', sm.get('links', [])))
# Also check DB for actual saved count
db.expire_all()
saved_count = db.query(CompanySocialMedia).filter_by(company_id=company.id).count()
results['social'] = 'OK (%d profili)' % saved_count
print(" -> OK: %d profili zapisanych w bazie" % saved_count)
except Exception as e:
results['social'] = 'ERROR: %s' % str(e)[:80]
print(" -> ERROR: %s" % str(e)[:80])
@ -203,7 +208,9 @@ def arm_company(company_id, force=False):
gbp_service = GBPAuditService(db)
gbp_result = gbp_service.audit_company(company.id)
if gbp_result:
score = gbp_result.get('completeness_score', gbp_result.get('score', '?'))
score = gbp_result.completeness_score
# Save to database
gbp_service.save_audit(gbp_result, source='script')
results['gbp'] = 'OK (score: %s)' % score
print(" -> OK: Score=%s" % score)
else: