feat: Add InvestorInsightCache model and implement caching for investor insights

This commit is contained in:
bolade
2025-10-17 23:15:57 +01:00
parent 390ecee9ed
commit 228a67cc49
9 changed files with 233 additions and 162 deletions
+9 -4
View File
@@ -34,7 +34,6 @@ class ReportGenerator:
# Render HTML from template
template = self.env.get_template("report.html")
html_content = template.render(**context)
# Convert HTML to PDF using Playwright
pdf_bytes = await self._html_to_pdf(html_content)
@@ -104,7 +103,11 @@ class ReportGenerator:
project_valuation = project_data.get("valuation", 0)
check_lower = investor_data.get("check_size_lower") or 0
check_upper = investor_data.get("check_size_upper") or float("inf")
if check_lower and check_upper and check_lower <= project_valuation <= check_upper:
if (
check_lower
and check_upper
and check_lower <= project_valuation <= check_upper
):
score += weights["check_size"]
# Thesis alignment (simplified)
@@ -153,10 +156,12 @@ class ReportGenerator:
# Geography criterion
investor_geo = investor_data.get("geographic_focus") or "N/A"
project_geo = project_data.get("location") or "N/A"
# Safe comparison handling None values
if investor_geo == "N/A" or project_geo == "N/A":
geo_match = "N/A" if investor_geo == "N/A" and project_geo == "N/A" else "Mismatch"
geo_match = (
"N/A" if investor_geo == "N/A" and project_geo == "N/A" else "Mismatch"
)
else:
investor_geo_lower = investor_geo.lower()
project_geo_lower = project_geo.lower()