Respect external filter in metrics and graph
Some checks failed
docker-build / build (push) Has been cancelled

This commit is contained in:
2025-11-20 09:54:41 -05:00
parent b0c9d319ef
commit 93774c025f
3 changed files with 161 additions and 40 deletions

View File

@@ -267,6 +267,10 @@
if (!graphOverlay || !graphUiAvailable()) {
return;
}
const includeExternal = externalToggle ? !!externalToggle.checked : false;
if (graphUiAvailable() && typeof window.GraphUI.setIncludeExternal === "function") {
window.GraphUI.setIncludeExternal(includeExternal);
}
lastFocusBeforeModal =
document.activeElement instanceof HTMLElement ? document.activeElement : null;
graphOverlay.classList.add("active");
@@ -282,7 +286,10 @@
graphVideoField.value = videoId;
}
if (videoId) {
window.GraphUI.load(videoId, undefined, undefined, { updateInputs: true });
window.GraphUI.load(videoId, undefined, undefined, {
updateInputs: true,
includeExternal,
});
}
window.GraphUI.focusInput();
});
@@ -1020,7 +1027,7 @@
}
}
function renderMetrics(data) {
function renderMetrics(data) {
if (!metricsContent) return;
metricsContent.innerHTML = "";
if (!data) return;
@@ -1058,7 +1065,8 @@ async function loadMetrics() {
metricsStatus.textContent = "Loading metrics…";
}
try {
const res = await fetch("/api/metrics");
const includeExternal = externalToggle ? !!externalToggle.checked : false;
const res = await fetch(`/api/metrics?external=${includeExternal ? "1" : "0"}`);
const data = await res.json();
renderMetrics(data);
metricsContainer.dataset.loaded = "1";
@@ -1325,6 +1333,11 @@ async function updateFrequencyChart(term, channels, year, queryMode, toggles = {
} of ${payload.totalPages}`;
(payload.items || []).forEach((item) => {
const isExternal = !!item.external_reference;
const hasTitle = typeof item.title === "string" && item.title.trim().length > 0;
if (isExternal && !hasTitle) {
return;
}
const el = document.createElement("div");
el.className = "item";
const titleHtml =
@@ -1685,6 +1698,10 @@ async function updateFrequencyChart(term, channels, year, queryMode, toggles = {
settings.external = !!externalToggle.checked;
persistSettings();
loadChannels().then(() => runSearch(0));
loadMetrics();
if (graphUiAvailable()) {
window.GraphUI.setIncludeExternal(settings.external);
}
});
}
if (queryToggle) {