feat: Frontend Inspector Upgrade (CRM & Strategy View)

This commit is contained in:
Moltbot-Jarvis
2026-02-18 10:22:20 +00:00
parent 31b2c24fdd
commit 5900ad028b
2 changed files with 212 additions and 1078 deletions

View File

@@ -194,7 +194,34 @@ def get_company(company_id: int, db: Session = Depends(get_db), username: str =
).filter(Company.id == company_id).first()
if not company:
raise HTTPException(404, detail="Company not found")
return company
# Enrich with Industry Details (Strategy)
industry_details = None
if company.industry_ai:
ind = db.query(Industry).filter(Industry.name == company.industry_ai).first()
if ind:
industry_details = {
"pains": ind.pains,
"gains": ind.gains,
"priority": ind.priority,
"notes": ind.notes,
"ops_focus_secondary": ind.ops_focus_secondary
}
# HACK: Attach to response object (Pydantic would be cleaner, but this works for fast prototyping)
# We convert to dict and append
resp = company.__dict__.copy()
resp["industry_details"] = industry_details
# Handle SQLAlchemy internal state
if "_sa_instance_state" in resp: del resp["_sa_instance_state"]
# Handle relationships manually if needed, or let FastAPI encode the SQLAlchemy model + extra dict
# Better: return a custom dict merging both
# Since we use joinedload, relationships are loaded.
# Let's rely on FastAPI's ability to serialize the object, but we need to inject the extra field.
# The safest way without changing Pydantic schemas everywhere is to return a dict.
return {**resp, "enrichment_data": company.enrichment_data, "contacts": company.contacts, "signals": company.signals}
@app.post("/api/companies")
def create_company(company: CompanyCreate, db: Session = Depends(get_db), username: str = Depends(authenticate_user)):

File diff suppressed because it is too large Load Diff