feat: Enhance project and scenario creation with monitoring metrics
- Added monitoring metrics for project creation success and error handling in `ProjectRepository`. - Implemented similar monitoring for scenario creation in `ScenarioRepository`. - Refactored `run_monte_carlo` function in `simulation.py` to include timing and success/error metrics. - Introduced new CSS styles for headers, alerts, and navigation buttons in `main.css` and `projects.css`. - Created a new JavaScript file for navigation logic to handle chevron buttons. - Updated HTML templates to include new navigation buttons and improved styling for buttons. - Added tests for reporting service and routes to ensure proper functionality and access control. - Removed unused imports and optimized existing test files for better clarity and performance.
This commit is contained in:
@@ -15,7 +15,6 @@ from models import (
|
||||
PricingImpuritySettings,
|
||||
PricingMetalSettings,
|
||||
PricingSettings,
|
||||
ResourceType,
|
||||
Role,
|
||||
Scenario,
|
||||
ScenarioStatus,
|
||||
@@ -88,8 +87,12 @@ class ProjectRepository:
|
||||
try:
|
||||
self.session.flush()
|
||||
except IntegrityError as exc: # pragma: no cover - reliance on DB constraints
|
||||
from monitoring.metrics import observe_project_operation
|
||||
observe_project_operation("create", "error")
|
||||
raise EntityConflictError(
|
||||
"Project violates uniqueness constraints") from exc
|
||||
from monitoring.metrics import observe_project_operation
|
||||
observe_project_operation("create", "success")
|
||||
return project
|
||||
|
||||
def find_by_names(self, names: Iterable[str]) -> Mapping[str, Project]:
|
||||
@@ -251,7 +254,11 @@ class ScenarioRepository:
|
||||
try:
|
||||
self.session.flush()
|
||||
except IntegrityError as exc: # pragma: no cover
|
||||
from monitoring.metrics import observe_scenario_operation
|
||||
observe_scenario_operation("create", "error")
|
||||
raise EntityConflictError("Scenario violates constraints") from exc
|
||||
from monitoring.metrics import observe_scenario_operation
|
||||
observe_scenario_operation("create", "success")
|
||||
return scenario
|
||||
|
||||
def find_by_project_and_names(
|
||||
|
||||
Reference in New Issue
Block a user