MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / fetch_channel_stats

Function fetch_channel_stats

core/tasks.py:424–463  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

422
423
424def fetch_channel_stats():
425 redis_client = RedisClient.get_client()
426
427 try:
428 # Basic info for all channels
429 channel_pattern = "live:channel:*:metadata"
430 all_channels = []
431
432 # Extract channel IDs from keys
433 cursor = 0
434 while True:
435 cursor, keys = redis_client.scan(cursor, match=channel_pattern)
436 for key in keys:
437 channel_id_match = re.search(r"live:channel:(.*):metadata", key)
438 if channel_id_match:
439 ch_id = channel_id_match.group(1)
440 channel_info = ChannelStatus.get_basic_channel_info(ch_id)
441 if channel_info:
442 all_channels.append(channel_info)
443
444 if cursor == 0:
445 break
446
447 send_websocket_update(
448 "updates",
449 "update",
450 {
451 "success": True,
452 "type": "channel_stats",
453 "stats": json.dumps({'channels': all_channels, 'count': len(all_channels)})
454 },
455 collect_garbage=True
456 )
457
458 # Explicitly clean up large data structures
459 all_channels = None
460
461 except Exception as e:
462 logger.error(f"Error in channel_status: {e}", exc_info=True)
463 return
464
465@shared_task
466def rehash_streams(keys):

Callers 1

beat_periodic_taskFunction · 0.70

Calls 5

send_websocket_updateFunction · 0.90
get_clientMethod · 0.80
scanMethod · 0.80
searchMethod · 0.80

Tested by

no test coverage detected