File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333print (f"Interval: { res .data .interval } " )
3434print ("\n Polling for activity (Ctrl+C to stop)...\n " )
3535
36- running = True
37-
3836def cleanup (_sig , _frame ):
39- global running
40- running = False
37+ print ("\n Stopping monitor..." )
38+ sgai .monitor .delete (monitor_id )
39+ print ("Monitor deleted" )
40+ exit (0 )
4141
4242signal .signal (signal .SIGINT , cleanup )
4343
44- while running :
44+ seen_ids = set ()
45+
46+ while True :
4547 activity = sgai .monitor .activity (monitor_id )
4648 if activity .status == "success" and activity .data :
4749 for tick in activity .data .ticks :
50+ if tick .id in seen_ids :
51+ continue
52+ seen_ids .add (tick .id )
53+
4854 changes = "CHANGED" if tick .changed else "no change"
4955 print (f"[{ tick .created_at } ] { tick .status } - { changes } ({ tick .elapsed_ms } ms)" )
5056 diffs = tick .diffs .model_dump (exclude_none = True )
5157 if diffs :
5258 print (f" Diffs: { json .dumps (diffs , indent = 2 )} " )
59+ elif tick .changed :
60+ print (" (no diffs data)" )
5361 time .sleep (30 )
54-
55- print ("\n Stopping monitor..." )
56- sgai .monitor .delete (monitor_id )
57- print ("Monitor deleted" )
Original file line number Diff line number Diff line change @@ -32,16 +32,24 @@ async def main():
3232 print (f"Interval: { res .data .interval } " )
3333 print ("\n Polling for activity (Ctrl+C to stop)...\n " )
3434
35+ seen_ids = set ()
36+
3537 try :
3638 while True :
3739 activity = await sgai .monitor .activity (monitor_id )
3840 if activity .status == "success" and activity .data :
3941 for tick in activity .data .ticks :
42+ if tick .id in seen_ids :
43+ continue
44+ seen_ids .add (tick .id )
45+
4046 changes = "CHANGED" if tick .changed else "no change"
4147 print (f"[{ tick .created_at } ] { tick .status } - { changes } ({ tick .elapsed_ms } ms)" )
4248 diffs = tick .diffs .model_dump (exclude_none = True )
4349 if diffs :
4450 print (f" Diffs: { json .dumps (diffs , indent = 2 )} " )
51+ elif tick .changed :
52+ print (" (no diffs data)" )
4553 await asyncio .sleep (30 )
4654 except asyncio .CancelledError :
4755 pass
Original file line number Diff line number Diff line change 3535print ("Webhook configured" )
3636print ("\n Polling for activity (Ctrl+C to stop)...\n " )
3737
38- running = True
39-
4038def cleanup (_sig , _frame ):
41- global running
42- running = False
39+ print ("\n Stopping monitor..." )
40+ sgai .monitor .delete (monitor_id )
41+ print ("Monitor deleted" )
42+ exit (0 )
4343
4444signal .signal (signal .SIGINT , cleanup )
4545
46- while running :
46+ seen_ids = set ()
47+
48+ while True :
4749 activity = sgai .monitor .activity (monitor_id )
4850 if activity .status == "success" and activity .data :
4951 for tick in activity .data .ticks :
52+ if tick .id in seen_ids :
53+ continue
54+ seen_ids .add (tick .id )
55+
5056 changes = "CHANGED" if tick .changed else "no change"
5157 print (f"[{ tick .created_at } ] { tick .status } - { changes } ({ tick .elapsed_ms } ms)" )
5258 diffs = tick .diffs .model_dump (exclude_none = True )
5359 if diffs :
5460 print (f" Diffs: { json .dumps (diffs , indent = 2 )} " )
61+ elif tick .changed :
62+ print (" (no diffs data)" )
5563 time .sleep (30 )
56-
57- print ("\n Stopping monitor..." )
58- sgai .monitor .delete (monitor_id )
59- print ("Monitor deleted" )
Original file line number Diff line number Diff line change @@ -34,16 +34,24 @@ async def main():
3434 print ("Webhook configured" )
3535 print ("\n Polling for activity (Ctrl+C to stop)...\n " )
3636
37+ seen_ids = set ()
38+
3739 try :
3840 while True :
3941 activity = await sgai .monitor .activity (monitor_id )
4042 if activity .status == "success" and activity .data :
4143 for tick in activity .data .ticks :
44+ if tick .id in seen_ids :
45+ continue
46+ seen_ids .add (tick .id )
47+
4248 changes = "CHANGED" if tick .changed else "no change"
4349 print (f"[{ tick .created_at } ] { tick .status } - { changes } ({ tick .elapsed_ms } ms)" )
4450 diffs = tick .diffs .model_dump (exclude_none = True )
4551 if diffs :
4652 print (f" Diffs: { json .dumps (diffs , indent = 2 )} " )
53+ elif tick .changed :
54+ print (" (no diffs data)" )
4755 await asyncio .sleep (30 )
4856 except asyncio .CancelledError :
4957 pass
You can’t perform that action at this time.
0 commit comments