mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 10:45:27 +00:00
Fixed issue with recurring api calls.
This commit is contained in:
parent
870e77b137
commit
98f485bac9
3 changed files with 24 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue