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

Function getChannelWithMetadata

frontend/src/utils/pages/StatsUtils.js:77–117  ·  view source on GitHub ↗
(
  prevChannelHistory,
  ch,
  channelsByUUID,
  channels,
  streamProfiles
)

Source from the content-addressed store, hash-verified

75};
76
77const getChannelWithMetadata = (
78 prevChannelHistory,
79 ch,
80 channelsByUUID,
81 channels,
82 streamProfiles
83) => {
84 let bitrates = [];
85 if (prevChannelHistory[ch.channel_id]) {
86 bitrates = [...(prevChannelHistory[ch.channel_id].bitrates || [])];
87 const bitrate =
88 ch.total_bytes - prevChannelHistory[ch.channel_id].total_bytes;
89 if (bitrate > 0) {
90 bitrates.push(bitrate);
91 }
92
93 if (bitrates.length > 15) {
94 bitrates = bitrates.slice(1);
95 }
96 }
97
98 // Find corresponding channel data
99 const channelData =
100 channelsByUUID && ch.channel_id
101 ? channels[channelsByUUID[ch.channel_id]]
102 : null;
103
104 // Find stream profile
105 const streamProfile = streamProfiles.find(
106 (profile) => profile.id == parseInt(ch.stream_profile)
107 );
108
109 return {
110 ...ch,
111 ...(channelData || {}), // Safely merge channel data if available
112 bitrates,
113 stream_profile: streamProfile || { name: 'Unknown' },
114 // Make sure stream_id is set from the active stream info
115 stream_id: ch.stream_id || null,
116 };
117};
118
119export const getClientStats = (stats) => {
120 return Object.values(stats).reduce((acc, ch) => {

Callers 1

getStatsByChannelIdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected