Álvaro Valenzuela Valdes commited on
Commit
3a20815
·
1 Parent(s): 54ad6b4

fix: Resolve startup NameError and expand seed data for dashboard impact

Browse files
Files changed (1) hide show
  1. backend/app/main.py +55 -24
backend/app/main.py CHANGED
@@ -9,6 +9,7 @@ from app.database import engine, Base, SessionLocal
9
  from app.models.tender import TenderModel
10
  from app.models.analysis import AnalysisHistoryModel
11
  from app.models.company import CompanyProfileModel
 
12
  from datetime import datetime, timedelta
13
  import json
14
 
@@ -54,30 +55,60 @@ async def startup_event():
54
  ))
55
 
56
  # Software Tenders
57
- db.add(TenderModel(
58
- code="2394-15-LR24",
59
- name="ERP Implementation - Health Sector",
60
- description="Large scale ERP for hospital network.",
61
- buyer="Servicio de Salud",
62
- status="Publicada",
63
- closing_date=(datetime.now() + timedelta(days=15)).strftime("%Y-%m-%d"),
64
- estimated_amount=450000000,
65
- region="Metropolitana",
66
- sector="Software",
67
- source="Mercado Público"
68
- ))
69
- db.add(TenderModel(
70
- code="5021-10-LP24",
71
- name="AI Platform for Crime Analysis",
72
- description="Machine learning and predictive models.",
73
- buyer="Subsecretaría de Prevención del Delito",
74
- status="Publicada",
75
- closing_date=(datetime.now() + timedelta(days=10)).strftime("%Y-%m-%d"),
76
- estimated_amount=180000000,
77
- region="Nacional",
78
- sector="AI & Software",
79
- source="Mercado Público"
80
- ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  db.commit()
82
  except Exception as e:
83
  print(f"Seed error: {e}")
 
9
  from app.models.tender import TenderModel
10
  from app.models.analysis import AnalysisHistoryModel
11
  from app.models.company import CompanyProfileModel
12
+ from app.config import settings
13
  from datetime import datetime, timedelta
14
  import json
15
 
 
55
  ))
56
 
57
  # Software Tenders
58
+ tenders_to_add = [
59
+ TenderModel(
60
+ code="2394-15-LR24",
61
+ name="ERP Implementation - Health Sector",
62
+ description="Large scale ERP for hospital network.",
63
+ buyer="Servicio de Salud",
64
+ status="Publicada",
65
+ closing_date=(datetime.now() + timedelta(days=15)).strftime("%Y-%m-%d"),
66
+ estimated_amount=450000000,
67
+ region="Metropolitana",
68
+ sector="Software",
69
+ source="Mercado Público"
70
+ ),
71
+ TenderModel(
72
+ code="5021-10-LP24",
73
+ name="AI Platform for Crime Analysis",
74
+ description="Machine learning and predictive models.",
75
+ buyer="Subsecretaría de Prevención del Delito",
76
+ status="Publicada",
77
+ closing_date=(datetime.now() + timedelta(days=10)).strftime("%Y-%m-%d"),
78
+ estimated_amount=180000000,
79
+ region="Nacional",
80
+ sector="AI & Software",
81
+ source="Mercado Público"
82
+ ),
83
+ TenderModel(
84
+ code="1022-5-LP24",
85
+ name="Cybersecurity Operations Center (SOC)",
86
+ description="24/7 monitoring and incident response.",
87
+ buyer="Ministerio del Interior",
88
+ status="Publicada",
89
+ closing_date=(datetime.now() + timedelta(days=5)).strftime("%Y-%m-%d"),
90
+ estimated_amount=320000000,
91
+ region="Metropolitana",
92
+ sector="Cybersecurity",
93
+ source="Mercado Público"
94
+ ),
95
+ TenderModel(
96
+ code="8821-2-LR24",
97
+ name="Cloud Migration Strategy",
98
+ description="Migration of legacy systems to AWS/Azure.",
99
+ buyer="Tesorería General",
100
+ status="Publicada",
101
+ closing_date=(datetime.now() + timedelta(days=25)).strftime("%Y-%m-%d"),
102
+ estimated_amount=120000000,
103
+ region="Valparaíso",
104
+ sector="Cloud",
105
+ source="Mercado Público"
106
+ )
107
+ ]
108
+ for t in tenders_to_add:
109
+ if not db.query(TenderModel).filter(TenderModel.code == t.code).first():
110
+ db.add(t)
111
+
112
  db.commit()
113
  except Exception as e:
114
  print(f"Seed error: {e}")