Googolplexic commited on
Commit
76a5cce
·
1 Parent(s): 53f56de
Files changed (2) hide show
  1. api_monitor.py +7 -8
  2. app.py +5 -5
api_monitor.py CHANGED
@@ -432,7 +432,6 @@ async def activate_monitoring(config_id, mcp_api_key):
432
  this
433
  """
434
 
435
-
436
  # Attempt to create the scheduler
437
  try:
438
  if not mcp_api_key or not mcp_api_key.strip() or mcp_api_key == "":
@@ -443,7 +442,7 @@ async def activate_monitoring(config_id, mcp_api_key):
443
  "message": "MCP API key is required",
444
  "config_id": None,
445
  }
446
-
447
  # Verify the MCP API key with the key generation server first
448
  key_verification = verify_mcp_api_key(mcp_api_key)
449
  if not key_verification["success"]:
@@ -474,7 +473,7 @@ async def activate_monitoring(config_id, mcp_api_key):
474
  "message": "Invalid mcp_api_key. You are not authorized to activate this configuration.",
475
  "config_id": config_id,
476
  }
477
-
478
  # Extract scheduling parameters
479
  name = config.get("name", "Unknown")
480
  schedule_interval_minutes = float(config.get("schedule_interval_minutes", 20))
@@ -492,7 +491,7 @@ async def activate_monitoring(config_id, mcp_api_key):
492
  stop_at = datetime.fromisoformat(
493
  str(stop_at)
494
  )
495
-
496
  # Job function to make actual API calls
497
 
498
  def api_monitoring_job():
@@ -650,7 +649,7 @@ async def activate_monitoring(config_id, mcp_api_key):
650
  print(
651
  f"Failed to log error to database: {db_exc}"
652
  )
653
-
654
  # Setup AsyncIO scheduler
655
 
656
  scheduler = AsyncIOScheduler()
@@ -664,9 +663,9 @@ async def activate_monitoring(config_id, mcp_api_key):
664
  id=f"monitor_{config_id}",
665
  )
666
  scheduler.start()
667
- # Mark config as active (only once, on first run)
668
  if not config["is_active"]:
669
- conn.execute(
670
  """
671
  UPDATE api_configurations SET is_active = %s WHERE config_id = %s
672
  """,
@@ -1007,4 +1006,4 @@ def retrieve_monitored_data(config_id, mcp_api_key, mode="summary"):
1007
  "success": False,
1008
  "message": f"Database connection failed: {str(e)}",
1009
  "data": [],
1010
- }
 
432
  this
433
  """
434
 
 
435
  # Attempt to create the scheduler
436
  try:
437
  if not mcp_api_key or not mcp_api_key.strip() or mcp_api_key == "":
 
442
  "message": "MCP API key is required",
443
  "config_id": None,
444
  }
445
+
446
  # Verify the MCP API key with the key generation server first
447
  key_verification = verify_mcp_api_key(mcp_api_key)
448
  if not key_verification["success"]:
 
473
  "message": "Invalid mcp_api_key. You are not authorized to activate this configuration.",
474
  "config_id": config_id,
475
  }
476
+
477
  # Extract scheduling parameters
478
  name = config.get("name", "Unknown")
479
  schedule_interval_minutes = float(config.get("schedule_interval_minutes", 20))
 
491
  stop_at = datetime.fromisoformat(
492
  str(stop_at)
493
  )
494
+
495
  # Job function to make actual API calls
496
 
497
  def api_monitoring_job():
 
649
  print(
650
  f"Failed to log error to database: {db_exc}"
651
  )
652
+
653
  # Setup AsyncIO scheduler
654
 
655
  scheduler = AsyncIOScheduler()
 
663
  id=f"monitor_{config_id}",
664
  )
665
  scheduler.start()
666
+ # Mark config as active (only once, on first run)
667
  if not config["is_active"]:
668
+ cur.execute(
669
  """
670
  UPDATE api_configurations SET is_active = %s WHERE config_id = %s
671
  """,
 
1006
  "success": False,
1007
  "message": f"Database connection failed: {str(e)}",
1008
  "data": [],
1009
+ }
app.py CHANGED
@@ -60,15 +60,15 @@ validation_tab = gr.Interface(
60
  examples=[
61
  [
62
  "test_mcp_key_123",
63
- "Wind-up Tonberry Price Monitor",
64
- "Monitor Wind-up Tonberry (ID: 6184) market prices on Aether-Siren server every hour for one week",
65
  "GET",
66
  "https://universalis.app",
67
  "api/v2/Siren/6184",
68
- "listings: 1\nentries: 1",
69
- "Content-Type: application/json\nUser-Agent: FFXIV-Market-Monitor",
70
  "{}",
71
- 60,
72
  168,
73
  "",
74
  ],
 
60
  examples=[
61
  [
62
  "test_mcp_key_123",
63
+ "FFXIV Wind-up Tonberry Price Monitor",
64
+ "Monitor Wind-up Tonberry (ID: 6184) prices on Aether-Siren server every 30 minutes for one week",
65
  "GET",
66
  "https://universalis.app",
67
  "api/v2/Siren/6184",
68
+ "listings: 1\nentries: 1\nfields: listings.pricePerUnit,listings.quantity,listings.worldName",
69
+ "User-Agent: FFXIV-Price-Monitor/1.0",
70
  "{}",
71
+ 30,
72
  168,
73
  "",
74
  ],