Spaces:
Running
Running
Commit ·
321eaec
1
Parent(s): f152542
Mise à jour ingestion et traitement RNE/JORT
Browse files- app/api/v1/companies.py +2 -2
- app/models/schemas.py +1 -1
- app/services/data_loader.py +3 -0
- app/services/osint_links.py +1 -1
app/api/v1/companies.py
CHANGED
|
@@ -34,7 +34,7 @@ async def list_companies(
|
|
| 34 |
return clean_nans(data)
|
| 35 |
|
| 36 |
@router.get("/{company_id}", response_model=CompanyWithLinks)
|
| 37 |
-
async def read_company(company_id:
|
| 38 |
df = await get_companies_df()
|
| 39 |
company = df[df['id'] == company_id]
|
| 40 |
if company.empty:
|
|
@@ -46,6 +46,6 @@ async def read_company(company_id: int):
|
|
| 46 |
return clean_nans(data)
|
| 47 |
|
| 48 |
@router.get("/{company_id}/osint_links")
|
| 49 |
-
async def read_company_links(company_id:
|
| 50 |
return await get_company_links(company_id)
|
| 51 |
|
|
|
|
| 34 |
return clean_nans(data)
|
| 35 |
|
| 36 |
@router.get("/{company_id}", response_model=CompanyWithLinks)
|
| 37 |
+
async def read_company(company_id: str):
|
| 38 |
df = await get_companies_df()
|
| 39 |
company = df[df['id'] == company_id]
|
| 40 |
if company.empty:
|
|
|
|
| 46 |
return clean_nans(data)
|
| 47 |
|
| 48 |
@router.get("/{company_id}/osint_links")
|
| 49 |
+
async def read_company_links(company_id: str):
|
| 50 |
return await get_company_links(company_id)
|
| 51 |
|
app/models/schemas.py
CHANGED
|
@@ -2,7 +2,7 @@ from pydantic import BaseModel
|
|
| 2 |
from typing import List, Optional, Dict, Any
|
| 3 |
|
| 4 |
class Company(BaseModel):
|
| 5 |
-
id: Optional[
|
| 6 |
name: str
|
| 7 |
wilaya: str
|
| 8 |
delegation: Optional[str] = None
|
|
|
|
| 2 |
from typing import List, Optional, Dict, Any
|
| 3 |
|
| 4 |
class Company(BaseModel):
|
| 5 |
+
id: Optional[str] = None # Generated ID
|
| 6 |
name: str
|
| 7 |
wilaya: str
|
| 8 |
delegation: Optional[str] = None
|
app/services/data_loader.py
CHANGED
|
@@ -95,6 +95,9 @@ class DataLoader:
|
|
| 95 |
if 'id' not in df.columns:
|
| 96 |
df['id'] = range(1, len(df) + 1)
|
| 97 |
|
|
|
|
|
|
|
|
|
|
| 98 |
# Recalculate capital divergence if not already handled by SQL
|
| 99 |
# (In our current SQL view, we could add this, but keeping it here for safety for now)
|
| 100 |
threshold = float(os.getenv("CAPITAL_DIVERGENCE_THRESHOLD", 0.05))
|
|
|
|
| 95 |
if 'id' not in df.columns:
|
| 96 |
df['id'] = range(1, len(df) + 1)
|
| 97 |
|
| 98 |
+
# Ensure id is always string for consistent matching
|
| 99 |
+
df['id'] = df['id'].astype(str)
|
| 100 |
+
|
| 101 |
# Recalculate capital divergence if not already handled by SQL
|
| 102 |
# (In our current SQL view, we could add this, but keeping it here for safety for now)
|
| 103 |
threshold = float(os.getenv("CAPITAL_DIVERGENCE_THRESHOLD", 0.05))
|
app/services/osint_links.py
CHANGED
|
@@ -20,7 +20,7 @@ def generate_links(company_name: str, wilaya: str):
|
|
| 20 |
|
| 21 |
return links
|
| 22 |
|
| 23 |
-
async def get_company_links(company_id:
|
| 24 |
from app.services.data_loader import get_companies_df
|
| 25 |
df = await get_companies_df()
|
| 26 |
|
|
|
|
| 20 |
|
| 21 |
return links
|
| 22 |
|
| 23 |
+
async def get_company_links(company_id: str):
|
| 24 |
from app.services.data_loader import get_companies_df
|
| 25 |
df = await get_companies_df()
|
| 26 |
|