refactor(prospecting): migrate SVC-006 transaction control to endpoint level
Some checks failed
Some checks failed
Move db.commit() from services to API endpoints and Celery tasks. Services now use db.flush() only; endpoints own the transaction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -110,7 +110,7 @@ class EnrichmentService:
|
||||
if result["has_website"]:
|
||||
prospect.status = "active"
|
||||
|
||||
db.commit()
|
||||
db.flush()
|
||||
return result
|
||||
|
||||
def scan_tech_stack(self, db: Session, prospect: Prospect) -> ProspectTechProfile | None:
|
||||
@@ -177,7 +177,7 @@ class EnrichmentService:
|
||||
profile.scan_source = "basic_http"
|
||||
|
||||
prospect.last_tech_scan_at = datetime.now(UTC)
|
||||
db.commit()
|
||||
db.flush()
|
||||
return profile
|
||||
|
||||
except Exception as e:
|
||||
@@ -185,7 +185,7 @@ class EnrichmentService:
|
||||
if prospect.tech_profile:
|
||||
prospect.tech_profile.scan_error = str(e)
|
||||
prospect.last_tech_scan_at = datetime.now(UTC)
|
||||
db.commit()
|
||||
db.flush()
|
||||
return None
|
||||
|
||||
def scan_performance(self, db: Session, prospect: Prospect) -> ProspectPerformanceProfile | None:
|
||||
@@ -251,13 +251,13 @@ class EnrichmentService:
|
||||
profile.scan_strategy = "mobile"
|
||||
|
||||
prospect.last_perf_scan_at = datetime.now(UTC)
|
||||
db.commit()
|
||||
db.flush()
|
||||
return profile
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Performance scan failed for %s: %s", domain, e)
|
||||
prospect.last_perf_scan_at = datetime.now(UTC)
|
||||
db.commit()
|
||||
db.flush()
|
||||
return None
|
||||
|
||||
def scrape_contacts(self, db: Session, prospect: Prospect) -> list[ProspectContact]:
|
||||
@@ -339,7 +339,7 @@ class EnrichmentService:
|
||||
break
|
||||
|
||||
prospect.last_contact_scrape_at = datetime.now(UTC)
|
||||
db.commit()
|
||||
db.flush()
|
||||
return contacts
|
||||
|
||||
def _detect_cms(self, html: str) -> str | None:
|
||||
|
||||
Reference in New Issue
Block a user