YouTube worker: push status over the socket like the others (stop polling)
The date enricher was the odd one out — the dashboard polled /api/video/enrichment/youtube/status every 3s (flooding the access log) instead of using the shared WebSocket the other three workers push on. Now the existing _emit_video_enrichment_status_loop also emits 'enrichment:youtube' (same stats shape), and video-enrichment.js binds it on the socket alongside tmdb/tvdb/omdb. Removed the bespoke polling loop. One-time prime fetch on load stays (instant initial state); everything after is socket-driven. Consistent with the others.
This commit is contained in:
parent
9c3facfe7e
commit
3a24fc24b1
2 changed files with 15 additions and 13 deletions
|
|
@ -37271,6 +37271,14 @@ def _emit_video_enrichment_status_loop():
|
|||
socketio.emit(f'enrichment:{svc}', w.get_stats())
|
||||
except Exception as e:
|
||||
logger.debug(f"Error emitting video {svc} status: {e}")
|
||||
# The YouTube date enricher is a standalone daemon (not an engine worker),
|
||||
# but it reports the SAME stats shape — push it on the same socket so its
|
||||
# dashboard orb listens like the others (no /enrichment/youtube/status poll).
|
||||
try:
|
||||
from core.video.youtube_enrichment import get_youtube_date_enricher
|
||||
socketio.emit('enrichment:youtube', get_youtube_date_enricher().stats())
|
||||
except Exception as e:
|
||||
logger.debug(f"Error emitting video youtube status: {e}")
|
||||
|
||||
|
||||
def _emit_tool_progress_loop():
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var SERVICES = ['tmdb', 'tvdb', 'omdb']; // pushed over the shared socket
|
||||
var POLLED = ['youtube']; // standalone daemon → light polling
|
||||
var ALL = SERVICES.concat(POLLED);
|
||||
// All four push status over the shared socket every 2s (server emits
|
||||
// 'enrichment:<svc>') — including the standalone YouTube date enricher — so the
|
||||
// browser never polls /api/video/enrichment/<svc>/status.
|
||||
var SERVICES = ['tmdb', 'tvdb', 'omdb', 'youtube'];
|
||||
|
||||
function onVideoSide() {
|
||||
return document.body.getAttribute('data-side') === 'video';
|
||||
|
|
@ -74,13 +75,7 @@
|
|||
|
||||
// One-time fetch so the buttons aren't blank until the first socket push.
|
||||
function primeOnce() {
|
||||
if (onVideoSide() && !document.hidden) ALL.forEach(pollOne);
|
||||
}
|
||||
// The YouTube date enricher isn't on the socket — poll it so its orb reflects
|
||||
// activity (only while the video side is foregrounded).
|
||||
function pollPolledLoop() {
|
||||
if (onVideoSide() && !document.hidden) POLLED.forEach(pollOne);
|
||||
setTimeout(pollPolledLoop, 3000);
|
||||
if (onVideoSide() && !document.hidden) SERVICES.forEach(pollOne);
|
||||
}
|
||||
|
||||
// Listen on the shared socket (set up by core.js) for the server-pushed
|
||||
|
|
@ -112,7 +107,7 @@
|
|||
}
|
||||
|
||||
function init() {
|
||||
ALL.forEach(function (svc) {
|
||||
SERVICES.forEach(function (svc) {
|
||||
var b = btn(svc);
|
||||
if (b) b.addEventListener('click', function () { toggle(svc); });
|
||||
});
|
||||
|
|
@ -123,8 +118,7 @@
|
|||
});
|
||||
}
|
||||
primeOnce(); // instant initial state
|
||||
bindSocket(); // then the socket pushes updates for tmdb/tvdb/omdb
|
||||
pollPolledLoop(); // ...and poll the youtube enricher
|
||||
bindSocket(); // then the socket pushes updates for all four (incl. youtube)
|
||||
// Re-prime when the user returns to the tab (socket kept pushing, but a
|
||||
// quick fetch snaps the buttons current immediately).
|
||||
document.addEventListener('visibilitychange', function () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue