Fixed issue with recurring api calls.

This commit is contained in:
SergeantPanda 2025-09-05 11:37:49 -05:00
parent 870e77b137
commit 98f485bac9
3 changed files with 24 additions and 3 deletions

View file

@ -28,6 +28,7 @@ from apps.accounts.permissions import (
from .constants import ChannelState, EventType, StreamType, ChannelMetadataField
from .config_helper import ConfigHelper
from .services.channel_service import ChannelService
from core.utils import send_websocket_update
from .url_utils import (
generate_stream_url,
transform_url,
@ -633,6 +634,18 @@ def channel_status(request, channel_id=None):
if cursor == 0:
break
# Send WebSocket update with the stats
# Format it the same way the original Celery task did
send_websocket_update(
"updates",
"update",
{
"success": True,
"type": "channel_stats",
"stats": json.dumps({'channels': all_channels, 'count': len(all_channels)})
}
)
return JsonResponse({"channels": all_channels, "count": len(all_channels)})
except Exception as e:

View file

@ -1319,7 +1319,7 @@ export default class API {
static async fetchActiveChannelStats() {
try {
const response = await request(`${host}/proxy/ts/status/`);
const response = await request(`${host}/proxy/ts/status`);
return response;
} catch (e) {
errorNotification('Failed to fetch active channel stats', e);

View file

@ -831,9 +831,16 @@ const ChannelsPage = () => {
const response = await API.fetchActiveChannelStats();
if (response) {
setChannelStats(response);
} else {
console.log('API response was empty or null');
}
} catch (error) {
console.error('Error fetching channel stats:', error);
console.error('Error details:', {
message: error.message,
status: error.status,
body: error.body,
});
}
}, [setChannelStats]);
@ -868,6 +875,7 @@ const ChannelsPage = () => {
}, [fetchChannelStats]);
useEffect(() => {
console.log('Processing channel stats:', channelStats);
if (
!channelStats ||
!channelStats.channels ||
@ -934,7 +942,7 @@ const ChannelsPage = () => {
});
console.log('Processed active channels:', stats);
// Update clients based on new stats
const clientStats = Object.values(stats).reduce((acc, ch) => {
if (ch.clients && Array.isArray(ch.clients)) {
@ -948,7 +956,7 @@ const ChannelsPage = () => {
return acc;
}, []);
setClients(clientStats);
return stats;
});
}, [channelStats, channels, channelsByUUID, streamProfiles]);