Delete utils.py
Browse files
utils.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
import matplotlib.pyplot as plt
|
| 2 |
-
|
| 3 |
-
def validate_inputs(input_data):
|
| 4 |
-
"""
|
| 5 |
-
Validate input data for required fields and ranges.
|
| 6 |
-
"""
|
| 7 |
-
required_fields = [
|
| 8 |
-
"project_name", "phase", "task", "current_progress",
|
| 9 |
-
"task_expected_duration", "task_actual_duration", "workforce_gap",
|
| 10 |
-
"workforce_skill_level", "workforce_shift_hours", "weather_impact_score",
|
| 11 |
-
"weather_condition", "weather_forecast_date", "project_location"
|
| 12 |
-
]
|
| 13 |
-
for field in required_fields:
|
| 14 |
-
if not input_data[field]:
|
| 15 |
-
return f"Please select or fill in {field.replace('_', ' ').lower()}"
|
| 16 |
-
if not (0 <= input_data["current_progress"] <= 100):
|
| 17 |
-
return "Current progress must be between 0 and 100"
|
| 18 |
-
if not (0 <= input_data["workforce_gap"] <= 100):
|
| 19 |
-
return "Workforce gap must be between 0 and 100"
|
| 20 |
-
if not (0 <= input_data["weather_impact_score"] <= 100):
|
| 21 |
-
return "Weather impact score must be between 0 and 100"
|
| 22 |
-
return None
|
| 23 |
-
|
| 24 |
-
def generate_heatmap(delay_probability, label):
|
| 25 |
-
"""
|
| 26 |
-
Generate a Chart.js bar chart configuration to visualize delay probability.
|
| 27 |
-
Returns a Chart.js configuration dictionary.
|
| 28 |
-
"""
|
| 29 |
-
color = '#FF0000' if delay_probability > 75 else '#FFFF00' if delay_probability > 50 else '#00FF00'
|
| 30 |
-
chart_config = {
|
| 31 |
-
"type": "bar",
|
| 32 |
-
"data": {
|
| 33 |
-
"labels": [label],
|
| 34 |
-
"datasets": [{
|
| 35 |
-
"label": "Delay Probability (%)",
|
| 36 |
-
"data": [delay_probability],
|
| 37 |
-
"backgroundColor": [color],
|
| 38 |
-
"borderColor": ["#000000"],
|
| 39 |
-
"borderWidth": 1
|
| 40 |
-
}]
|
| 41 |
-
},
|
| 42 |
-
"options": {
|
| 43 |
-
"indexAxis": "y",
|
| 44 |
-
"scales": {
|
| 45 |
-
"x": {
|
| 46 |
-
"beginAtZero": True,
|
| 47 |
-
"max": 100,
|
| 48 |
-
"title": {"display": True, "text": "Delay Probability (%)"}
|
| 49 |
-
},
|
| 50 |
-
"y": {"title": {"display": True, "text": "Task"}}
|
| 51 |
-
},
|
| 52 |
-
"plugins": {
|
| 53 |
-
"title": {"display": True, "text": "Delay Risk Heatmap"}
|
| 54 |
-
}
|
| 55 |
-
}
|
| 56 |
-
}
|
| 57 |
-
return chart_config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|