gauravlochab commited on
Commit
28d3431
·
1 Parent(s): cefbde3

fix : avg runtime in roi graph

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -1130,19 +1130,19 @@ def create_combined_roi_time_series_graph(df):
1130
  )
1131
  return fig
1132
 
1133
- # Define fixed start date (May 15, 2025)
1134
- fixed_start_date = datetime(2025, 5, 15)
1135
- logger.info(f"Using fixed start date for ROI runtime calculation: {fixed_start_date}")
1136
 
1137
- # Calculate runtime for each agent from fixed start date
1138
  agent_runtimes = {}
1139
  for agent_id in df['agent_id'].unique():
1140
  agent_data = df[df['agent_id'] == agent_id]
1141
  agent_name = agent_data['agent_name'].iloc[0]
1142
- last_report = agent_data['timestamp'].max()
1143
- runtime_days = (last_report - fixed_start_date).total_seconds() / (24 * 3600) # Convert to days
 
1144
  agent_runtimes[agent_id] = {
1145
  'agent_name': agent_name,
 
1146
  'last_report': last_report,
1147
  'runtime_days': runtime_days
1148
  }
 
1130
  )
1131
  return fig
1132
 
1133
+ # Calculate runtime for each agent from their actual first data point
1134
+ logger.info(f"Calculating runtime for each agent from their actual start date")
 
1135
 
 
1136
  agent_runtimes = {}
1137
  for agent_id in df['agent_id'].unique():
1138
  agent_data = df[df['agent_id'] == agent_id]
1139
  agent_name = agent_data['agent_name'].iloc[0]
1140
+ first_report = agent_data['timestamp'].min() # Agent's actual start date
1141
+ last_report = agent_data['timestamp'].max() # Agent's last report
1142
+ runtime_days = (last_report - first_report).total_seconds() / (24 * 3600) # Convert to days
1143
  agent_runtimes[agent_id] = {
1144
  'agent_name': agent_name,
1145
+ 'first_report': first_report,
1146
  'last_report': last_report,
1147
  'runtime_days': runtime_days
1148
  }