github-actions[bot] commited on
Commit
3d1319b
ยท
1 Parent(s): 34c9b8e

deploy: backend from 50377d9

Browse files
main.py CHANGED
@@ -437,7 +437,6 @@ ROLE_POLICIES: Dict[str, Set[str]] = {
437
  "/api/analytics/class-insights": TEACHER_OR_ADMIN,
438
  "/api/analytics/refresh-cache": ADMIN_ONLY,
439
  "/api/testing/reset-data": ALL_APP_ROLES,
440
- "/api/ops/inference-metrics": ADMIN_ONLY,
441
  "/api/hf/monitoring": ADMIN_ONLY,
442
  "/api/dev/generate-mock-data": ADMIN_ONLY,
443
  "/api/analytics/config": TEACHER_OR_ADMIN,
@@ -9061,11 +9060,6 @@ class AsyncTaskCancelResponse(BaseModel):
9061
  message: str
9062
 
9063
 
9064
- class InferenceMetricsResponse(BaseModel):
9065
- success: bool
9066
- metrics: Dict[str, Any]
9067
-
9068
-
9069
  class HFMonitoringDataResponse(BaseModel):
9070
  success: bool
9071
  data: Dict[str, Any]
@@ -11585,18 +11579,6 @@ async def cancel_async_task(http_request: Request, task_id: str):
11585
  )
11586
 
11587
 
11588
- @app.get("/api/ops/inference-metrics", response_model=InferenceMetricsResponse)
11589
- async def get_inference_metrics(http_request: Request):
11590
- user = get_current_user(http_request)
11591
- if user.role != "admin":
11592
- raise HTTPException(status_code=403, detail="Forbidden for this role")
11593
-
11594
- client = get_inference_client()
11595
- metrics_snapshot = client.snapshot_metrics()
11596
- metrics_snapshot["pro_enabled"] = bool(getattr(client, "pro_enabled", False))
11597
- return InferenceMetricsResponse(success=True, metrics=metrics_snapshot)
11598
-
11599
-
11600
  @app.get("/api/hf/monitoring", response_model=HFMonitoringDataResponse)
11601
  async def get_hf_monitoring(http_request: Request):
11602
  """
 
437
  "/api/analytics/class-insights": TEACHER_OR_ADMIN,
438
  "/api/analytics/refresh-cache": ADMIN_ONLY,
439
  "/api/testing/reset-data": ALL_APP_ROLES,
 
440
  "/api/hf/monitoring": ADMIN_ONLY,
441
  "/api/dev/generate-mock-data": ADMIN_ONLY,
442
  "/api/analytics/config": TEACHER_OR_ADMIN,
 
9060
  message: str
9061
 
9062
 
 
 
 
 
 
9063
  class HFMonitoringDataResponse(BaseModel):
9064
  success: bool
9065
  data: Dict[str, Any]
 
11579
  )
11580
 
11581
 
 
 
 
 
 
 
 
 
 
 
 
 
11582
  @app.get("/api/hf/monitoring", response_model=HFMonitoringDataResponse)
11583
  async def get_hf_monitoring(http_request: Request):
11584
  """
routes/admin_routes.py CHANGED
@@ -202,7 +202,7 @@ async def upload_pdf(
202
  background_tasks: BackgroundTasks,
203
  subjectId: str = Form(...),
204
  subjectName: str = Form(...),
205
- semester: int = Form(...),
206
  quarter: int = Form(...),
207
  file: UploadFile = File(...),
208
  _admin=Depends(require_admin)
 
202
  background_tasks: BackgroundTasks,
203
  subjectId: str = Form(...),
204
  subjectName: str = Form(...),
205
+ semester: Optional[int] = Form(None),
206
  quarter: int = Form(...),
207
  file: UploadFile = File(...),
208
  _admin=Depends(require_admin)
routes/curriculum_routes.py CHANGED
@@ -31,7 +31,11 @@ class SubjectResponse(BaseModel):
31
  code: str
32
  name: str
33
  gradeLevel: str
34
- semester: str
 
 
 
 
35
  color: str
36
  pdfAvailable: bool
37
  topics: list
 
31
  code: str
32
  name: str
33
  gradeLevel: str
34
+ semester: Optional[str] = None
35
+ quarters: Optional[list[str]] = None
36
+ termStructure: Optional[str] = None
37
+ available: Optional[bool] = True
38
+ shelved: Optional[bool] = False
39
  color: str
40
  pdfAvailable: bool
41
  topics: list
services/curriculum_service.py CHANGED
@@ -19,6 +19,10 @@ _STATIC_SUBJECTS = [
19
  "name": "General Mathematics",
20
  "gradeLevel": "Grade 11",
21
  "semester": "1st Semester",
 
 
 
 
22
  "color": "from-blue-500 to-cyan-500",
23
  "pdfAvailable": True,
24
  "topics": [
@@ -45,14 +49,37 @@ _STATIC_SUBJECTS = [
45
  {"id": "gen-math-021", "name": "Validity of Arguments", "unit": "Logic and Mathematical Reasoning"},
46
  ]
47
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  {
49
  "id": "stats-prob",
50
  "code": "STAT&PROB",
51
  "name": "Statistics and Probability",
52
  "gradeLevel": "Grade 11",
53
  "semester": "2nd Semester",
 
 
 
 
54
  "color": "from-sky-500 to-cyan-500",
55
- "pdfAvailable": True,
56
  "topics": [
57
  {"id": "stat-001", "name": "Random Variables", "unit": "Random Variables"},
58
  {"id": "stat-002", "name": "Discrete Probability Distributions", "unit": "Random Variables"},
@@ -70,6 +97,20 @@ _STATIC_SUBJECTS = [
70
  {"id": "stat-014", "name": "Correlation and Regression", "unit": "Correlation and Regression"},
71
  ]
72
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  ]
74
 
75
  _firestore_db = None
 
19
  "name": "General Mathematics",
20
  "gradeLevel": "Grade 11",
21
  "semester": "1st Semester",
22
+ "quarters": ["Q1", "Q2", "Q3", "Q4"],
23
+ "termStructure": "quarterly",
24
+ "available": True,
25
+ "shelved": False,
26
  "color": "from-blue-500 to-cyan-500",
27
  "pdfAvailable": True,
28
  "topics": [
 
49
  {"id": "gen-math-021", "name": "Validity of Arguments", "unit": "Logic and Mathematical Reasoning"},
50
  ]
51
  },
52
+ {
53
+ "id": "finite-math",
54
+ "code": "FINITE MATH",
55
+ "name": "Finite Mathematics",
56
+ "gradeLevel": "Grade 11",
57
+ "semester": None,
58
+ "quarters": [],
59
+ "termStructure": "year-long",
60
+ "available": True,
61
+ "shelved": False,
62
+ "color": "from-violet-500 to-purple-500",
63
+ "pdfAvailable": True,
64
+ "topics": [
65
+ {"id": "finite-001", "name": "Geometry of Design", "unit": "Unit 1"},
66
+ {"id": "finite-002", "name": "Patterns in Nature and Art", "unit": "Unit 2"},
67
+ {"id": "finite-003", "name": "Introduction to Matrices", "unit": "Unit 3"},
68
+ {"id": "finite-004", "name": "Introduction to Linear Programming", "unit": "Unit 4"},
69
+ ]
70
+ },
71
  {
72
  "id": "stats-prob",
73
  "code": "STAT&PROB",
74
  "name": "Statistics and Probability",
75
  "gradeLevel": "Grade 11",
76
  "semester": "2nd Semester",
77
+ "quarters": [],
78
+ "termStructure": "shelved",
79
+ "available": False,
80
+ "shelved": True,
81
  "color": "from-sky-500 to-cyan-500",
82
+ "pdfAvailable": False,
83
  "topics": [
84
  {"id": "stat-001", "name": "Random Variables", "unit": "Random Variables"},
85
  {"id": "stat-002", "name": "Discrete Probability Distributions", "unit": "Random Variables"},
 
97
  {"id": "stat-014", "name": "Correlation and Regression", "unit": "Correlation and Regression"},
98
  ]
99
  },
100
+ {
101
+ "id": "business-math",
102
+ "code": "BUS MATH",
103
+ "name": "Business Mathematics",
104
+ "gradeLevel": "Grade 11",
105
+ "semester": "1st Semester",
106
+ "quarters": [],
107
+ "termStructure": "shelved",
108
+ "available": False,
109
+ "shelved": True,
110
+ "color": "from-amber-500 to-orange-500",
111
+ "pdfAvailable": False,
112
+ "topics": []
113
+ },
114
  ]
115
 
116
  _firestore_db = None
tests/test_api.py CHANGED
@@ -1230,33 +1230,6 @@ class TestAsyncGenerationTasks:
1230
  assert cancel_payload["taskId"] == task_id
1231
  assert cancel_payload["status"] in {"cancelled", "cancelling"}
1232
 
1233
- def test_inference_metrics_requires_admin(self):
1234
- # Test with a non-admin mock to verify role check works
1235
- with patch.object(main_module.firebase_auth, "verify_id_token", return_value={
1236
- "uid": "teacher-uid",
1237
- "email": "teacher@example.com",
1238
- "role": "teacher",
1239
- }):
1240
- response = client.get("/api/ops/inference-metrics")
1241
- assert response.status_code == 403
1242
-
1243
- def test_inference_metrics_admin_success(self):
1244
- # Set admin role directly to ensure it persists
1245
- main_module.firebase_auth.verify_id_token = MagicMock(
1246
- return_value={
1247
- "uid": "admin-uid",
1248
- "email": "admin@example.com",
1249
- "role": "admin",
1250
- }
1251
- )
1252
- response = client.get("/api/ops/inference-metrics")
1253
- assert response.status_code == 200
1254
- payload = response.json()
1255
- assert payload["success"] is True
1256
- assert "metrics" in payload
1257
- assert "requests_total" in payload["metrics"]
1258
-
1259
-
1260
  # โ”€โ”€โ”€ Calculator โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1261
 
1262
 
 
1230
  assert cancel_payload["taskId"] == task_id
1231
  assert cancel_payload["status"] in {"cancelled", "cancelling"}
1232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1233
  # โ”€โ”€โ”€ Calculator โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1234
 
1235