Remove players deleted from Yodeck instead of showing them as offline
Poll loop now deletes DB rows for players no longer returned by the Yodeck API, and Zabbix sync deletes the corresponding hosts from the Yodeck Players group. Both actions are reflected in the activity log. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,8 +14,12 @@ def poll_yodeck():
|
||||
players = yd.get_all_screens()
|
||||
for p in players:
|
||||
db.upsert_player(p)
|
||||
current_ids = [p['id'] for p in players]
|
||||
removed = db.delete_players_not_in(current_ids)
|
||||
msg = f"Fetched {len(players)} players from Yodeck API"
|
||||
db.add_log('yodeck_fetch', msg, {'count': len(players)})
|
||||
if removed:
|
||||
msg += f", removed {removed} deleted player(s)"
|
||||
db.add_log('yodeck_fetch', msg, {'count': len(players), 'removed': removed})
|
||||
log.info(msg)
|
||||
# Sync host list to Zabbix after a successful fetch
|
||||
sync_to_zabbix(players, db.add_log)
|
||||
|
||||
Reference in New Issue
Block a user