Googolplexic commited on
Commit
a8b8ea2
·
1 Parent(s): d92d648

Update schedule_interval_minutes to DECIMAL type and adjust validation logic

Browse files
Files changed (2) hide show
  1. api_monitor.py +6 -7
  2. schema.sql +1 -1
api_monitor.py CHANGED
@@ -153,12 +153,12 @@ def validate_api_configuration(
153
 
154
  if (
155
  not isinstance(schedule_interval_minutes, (int, float))
156
- or schedule_interval_minutes < 1
157
  or schedule_interval_minutes > 1440
158
  ):
159
  return {
160
  "success": False,
161
- "message": "Schedule interval must be between 1 and 1440 minutes",
162
  "config_id": None,
163
  }
164
 
@@ -218,7 +218,7 @@ def validate_api_configuration(
218
 
219
  # Calculate timestamps
220
  created_at = datetime.now()
221
- stop_at = parsed_start_time + timedelta(hours=stop_after_hours)
222
 
223
  # Store configuration
224
  try:
@@ -248,7 +248,7 @@ def validate_api_configuration(
248
  json.dumps(api_client.parse_key_value_string(header_keys_values)),
249
  additional_params,
250
  False,
251
- schedule_interval_minutes,
252
  parsed_start_time,
253
  stop_at.isoformat(),
254
  created_at,
@@ -343,7 +343,6 @@ def activate_monitoring(config_id, mcp_api_key):
343
  """
344
  try:
345
  conn = connect_to_db()
346
- # TODO: Implement activation logic here
347
  conn.close()
348
 
349
  return {
@@ -517,7 +516,7 @@ def retrieve_monitored_data(config_id, mcp_api_key, mode="summary"):
517
  elapsed_minutes = (now - start_dt).total_seconds() / 60
518
  if elapsed_minutes > 0:
519
  total_expected_calls = max(
520
- 1, int(elapsed_minutes / config["schedule_interval_minutes"])
521
  )
522
 
523
  # Get success/failure counts
@@ -668,7 +667,7 @@ if __name__ == "__main__":
668
  param_keys_values="",
669
  header_keys_values="",
670
  additional_params="{}",
671
- schedule_interval_minutes=20,
672
  stop_after_hours=24,
673
  start_at="",
674
  )
 
153
 
154
  if (
155
  not isinstance(schedule_interval_minutes, (int, float))
156
+ or schedule_interval_minutes <= 0
157
  or schedule_interval_minutes > 1440
158
  ):
159
  return {
160
  "success": False,
161
+ "message": "Schedule interval must be between 0 and 1440 minutes",
162
  "config_id": None,
163
  }
164
 
 
218
 
219
  # Calculate timestamps
220
  created_at = datetime.now()
221
+ stop_at = parsed_start_time + timedelta(hours=float(stop_after_hours))
222
 
223
  # Store configuration
224
  try:
 
248
  json.dumps(api_client.parse_key_value_string(header_keys_values)),
249
  additional_params,
250
  False,
251
+ float(schedule_interval_minutes),
252
  parsed_start_time,
253
  stop_at.isoformat(),
254
  created_at,
 
343
  """
344
  try:
345
  conn = connect_to_db()
 
346
  conn.close()
347
 
348
  return {
 
516
  elapsed_minutes = (now - start_dt).total_seconds() / 60
517
  if elapsed_minutes > 0:
518
  total_expected_calls = max(
519
+ 1, int(elapsed_minutes / float(config["schedule_interval_minutes"]))
520
  )
521
 
522
  # Get success/failure counts
 
667
  param_keys_values="",
668
  header_keys_values="",
669
  additional_params="{}",
670
+ schedule_interval_minutes=20.5,
671
  stop_after_hours=24,
672
  start_at="",
673
  )
schema.sql CHANGED
@@ -14,7 +14,7 @@ CREATE TABLE api_configurations (
14
  headers JSONB,
15
  additional_params JSONB,
16
  is_active BOOLEAN DEFAULT FALSE,
17
- schedule_interval_minutes INTEGER,
18
  start_at TIMESTAMP,
19
  stop_at TIMESTAMP,
20
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
 
14
  headers JSONB,
15
  additional_params JSONB,
16
  is_active BOOLEAN DEFAULT FALSE,
17
+ schedule_interval_minutes DECIMAL(10,2),
18
  start_at TIMESTAMP,
19
  stop_at TIMESTAMP,
20
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP