mirror of
https://github.com/SrIzan10/hctv.git
synced 2026-06-06 00:56:56 +00:00
fix metrics cardinality and stream key cache counts
This commit is contained in:
@@ -768,7 +768,12 @@ app.get(
|
||||
chatUser.isBot ? 'bot' : 'user',
|
||||
Buffer.byteLength(message)
|
||||
);
|
||||
recordUniqueChatter(chatUser.isBot ? 'bot' : 'user');
|
||||
const isFirstMessageFromUser =
|
||||
(await redis.sadd(`chat:unique-chatters:${targetUsername}`, chatUser.id)) === 1;
|
||||
|
||||
if (isFirstMessageFromUser) {
|
||||
recordUniqueChatter(chatUser.isBot ? 'bot' : 'user');
|
||||
}
|
||||
outcome = 'broadcast';
|
||||
}
|
||||
if (msg.type === 'emojiMsg') {
|
||||
|
||||
@@ -12,6 +12,7 @@ export default async function syncStreamKeys() {
|
||||
});
|
||||
|
||||
if (keys.length === 0) {
|
||||
setCacheEntryCount('stream_keys', 0);
|
||||
console.log('No stream keys found to sync.');
|
||||
return;
|
||||
}
|
||||
@@ -19,15 +20,17 @@ export default async function syncStreamKeys() {
|
||||
const redis = getRedisConnection();
|
||||
const pipeline = redis.pipeline();
|
||||
|
||||
let syncedKeyCount = 0;
|
||||
for (const key of keys) {
|
||||
if (key.channel && key.channel.name) {
|
||||
pipeline.set(`streamKey:${key.channel.name}`, key.key);
|
||||
syncedKeyCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
await pipeline.exec();
|
||||
setCacheEntryCount('stream_keys', keys.length);
|
||||
console.log(`Synced ${keys.length} stream keys to Redis`);
|
||||
setCacheEntryCount('stream_keys', syncedKeyCount);
|
||||
console.log(`Synced ${syncedKeyCount} stream keys to Redis`);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to sync stream keys to Redis:', error);
|
||||
|
||||
Reference in New Issue
Block a user