Add friendly scrape names and a completeness check
This commit is contained in:
+28
-5
@@ -866,7 +866,7 @@
|
||||
for (const job of jobs) {
|
||||
const row = el("div", `vk-bot-job vk-bot-job-${job.state}`);
|
||||
const head = el("div", "vk-bot-job-head");
|
||||
head.append(el("span", "vk-bot-job-title", channelLabel(job.chatId)));
|
||||
head.append(el("span", "vk-bot-job-title", scrapeName(job.chatId)));
|
||||
head.append(el("span", `vk-bot-state vk-bot-state-${job.state}`, job.state));
|
||||
|
||||
const parts = [`${job.pending} pending`];
|
||||
@@ -953,7 +953,7 @@
|
||||
if (status.failed) parts.push(`${status.failed} failed`);
|
||||
if (status.perMinute) parts.push(`${status.perMinute}/min`);
|
||||
if (status.pending > 0) parts.push(`ETA ${formatEta(status.etaMs)}`);
|
||||
if (status.currentScrapeId) parts.push(`on ${channelLabel(status.currentScrapeId)}`);
|
||||
if (status.currentScrapeId) parts.push(`on ${scrapeName(status.currentScrapeId)}`);
|
||||
head.append(el("span", "vk-bot-job-meta", parts.join(" \u00b7 ")));
|
||||
titleLane.append(head);
|
||||
|
||||
@@ -1005,7 +1005,7 @@
|
||||
if (status.recovered) parts.push(`${status.recovered} recovered`);
|
||||
if (status.deferred) parts.push(`${status.deferred} deferred`);
|
||||
if (status.gone) parts.push(`${status.gone} unavailable`);
|
||||
if (status.currentScrapeId) parts.push(`on ${channelLabel(status.currentScrapeId)}`);
|
||||
if (status.currentScrapeId) parts.push(`on ${scrapeName(status.currentScrapeId)}`);
|
||||
head.append(el("span", "vk-bot-job-meta", parts.join(" \u00b7 ")));
|
||||
recoverLane.append(head);
|
||||
|
||||
@@ -2451,6 +2451,20 @@
|
||||
return state.channels.find(channel => channel.id === channelId)?.label ?? channelId;
|
||||
}
|
||||
|
||||
/** Short scrape name: the first two words of the channel or group-chat name. */
|
||||
function scrapeName(channelId) {
|
||||
const label = channelLabel(channelId);
|
||||
const cleaned = label.includes("/#")
|
||||
? label.split("/#")[1]
|
||||
: label.replace(/\s*\((group DM|DM)\)\s*$/i, "");
|
||||
const words = cleaned
|
||||
.replace(/[_\-]+/g, " ")
|
||||
.split(/\s+/)
|
||||
.filter(Boolean)
|
||||
.slice(0, 2);
|
||||
return words.join(" ") || label;
|
||||
}
|
||||
|
||||
async function openHistoryModal() {
|
||||
const list = historyModal.querySelector("#history-list");
|
||||
list.replaceChildren(el("div", null, "loading..."));
|
||||
@@ -2469,7 +2483,9 @@
|
||||
for (const scrape of scrapes) {
|
||||
const media = scrape.media ?? {};
|
||||
const row = el("div", "vk-media-history-row");
|
||||
row.append(el("strong", null, channelLabel(scrape.channelId)));
|
||||
row.append(
|
||||
el("strong", null, `${scrapeName(scrape.channelId)} · ${scrape.id}`)
|
||||
);
|
||||
row.append(
|
||||
el(
|
||||
"span",
|
||||
@@ -2894,7 +2910,14 @@
|
||||
|
||||
list.replaceChildren();
|
||||
for (const scrape of scrapes) {
|
||||
list.append(el("div", null, `${scrape.id} · ${scrape.state} · ${formatBytes(scrape.bytes)}`));
|
||||
list.append(
|
||||
el(
|
||||
"div",
|
||||
null,
|
||||
`${scrapeName(scrape.channelId)} · ${scrape.id} · ${scrape.state} · ` +
|
||||
formatBytes(scrape.bytes)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const bytes = scrapes.reduce((sum, scrape) => sum + scrape.bytes, 0);
|
||||
|
||||
Reference in New Issue
Block a user