Refactor code structure for improved readability and maintainability

This commit is contained in:
bolade
2025-10-08 10:03:30 +01:00
parent 84e3c7b72a
commit 26a1197db0
7 changed files with 25 additions and 12 deletions
Binary file not shown.
+1 -1
View File
@@ -14,7 +14,7 @@ Base = declarative_base()
# Get absolute path to the preprocessor database
# APP_DIR = Path(__file__).parent.parent
# PREPROCESSOR_DB = APP_DIR.parent / "preprocessor" / "version_two.db"
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./version_two.db")
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./investors.db")
# Create engine
engine = create_engine(DATABASE_URL, echo=False)
Binary file not shown.
+11 -7
View File
@@ -18,22 +18,24 @@ router = APIRouter(tags=["Investor Routes"])
class InvestorCreate(BaseModel):
name: str
description: Optional[str] = None
website: Optional[str] = None
headquarters: Optional[str] = None
aum: int
check_size_lower: int
check_size_upper: int
geographic_focus: str
stage_focus: InvestmentStage
number_of_investments: int = 0
class InvestorUpdate(BaseModel):
name: Optional[str] = None
description: Optional[str] = None
website: Optional[str] = None
headquarters: Optional[str] = None
aum: Optional[int] = None
check_size_lower: Optional[int] = None
check_size_upper: Optional[int] = None
geographic_focus: Optional[str] = None
stage_focus: Optional[InvestmentStage] = None
number_of_investments: Optional[int] = None
@@ -155,8 +157,9 @@ def filter_investors(
)
# Apply filters
if stage:
query = query.filter(InvestorTable.stage_focus == stage)
# Note: stage filtering is now done at fund level via fund.investment_stages
# if stage:
# query = query.filter(InvestorTable.stage_focus == stage)
if min_check_size is not None:
query = query.filter(InvestorTable.check_size_lower >= min_check_size)
@@ -413,9 +416,10 @@ def find_similar_investors(
for candidate in candidates:
score = 0
# Stage focus match (30 points)
if candidate.stage_focus == target_investor.stage_focus:
score += 30
# Stage focus match is now handled at fund level
# Skip stage matching at investor level since stage_focus no longer exists
# if candidate.stage_focus == target_investor.stage_focus:
# score += 30
# Geographic focus match (20 points for exact, 10 for partial)
if candidate.geographic_focus and target_investor.geographic_focus:
+13 -4
View File
@@ -1,6 +1,6 @@
from datetime import datetime
from enum import Enum
from typing import List, Optional
from typing import Any, List, Optional
from pydantic import BaseModel
@@ -89,11 +89,20 @@ class InvestorSchema(BaseModel):
id: int
name: str
description: Optional[str]
website: Optional[str] = None
headquarters: Optional[str] = None
aum: int | None
aum_as_of_date: str | None = None
aum_source_url: str | None = None
check_size_lower: int | None
check_size_upper: int | None
geographic_focus: str | None
stage_focus: InvestmentStage
investment_thesis: Any = (
None # Flexible JSON field - can be list, dict, or list of dicts
)
portfolio_highlights: Any = (
None # Flexible JSON field - can be list, dict, or list of dicts
)
number_of_investments: int | None
created_at: Optional[datetime] = None
updated_at: Optional[datetime] = None
@@ -131,8 +140,8 @@ class InvestorFundData(BaseModel):
aum: int | None
aum_as_of_date: str | None
aum_source_url: str | None
investment_thesis: List[str] | None
portfolio_highlights: List[str] | None
investment_thesis: Any = None # Flexible JSON field
portfolio_highlights: Any = None # Flexible JSON field
number_of_investments: int | None
# Fund fields
BIN
View File
Binary file not shown.