Fragnet: reads checked against a live account; interval and one-off schedules

Inspect on a real Fragnet panel showed every read answers as the reader expects. Schedules that run every so often or once (interval_value, interval_unit, run_at) carry no cron fields, so they were shown as a cron of stars; they now read "every 6 hours" or "once, ...", and the page hides an empty label. Test and INTEGRATIONS.md updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-17 19:19:48 +01:00
1 parent 01fb5d6335
commit a91efcbfe2
4 files changed
+31 -5

No files matched your search

+18 -3
View File
@@ -241,6 +241,23 @@ export function parseNewBackup(raw: unknown): FragnetBackup | null {
return parseBackups({ data: [raw] })[0] ?? null;
}
/**
* When a schedule runs, as one line. Most carry a cron (the five fields, joined); the panel also has schedules that run every so often (`has_interval`, `interval_value`, `interval_unit`) or
* once (`run_at`), whose cron object says nothing — those read "every 6 hours" or "once, 2026-06-02 04:00", rather than a cron of stars that would claim "every minute".
*/
function whenItRuns(s: Record<string, unknown>): string {
const c = obj(s.cron);
const fields = [c.minute, c.hour, c.day_of_month, c.month, c.day_of_week];
const given = (x: unknown) => (typeof x === "string" && x.trim() !== "") || typeof x === "number";
if (fields.some(given)) return fields.map((x) => (given(x) ? String(x) : "*")).join(" ");
const every = num(s.interval_value);
const unit = str(s.interval_unit);
if (s.has_interval === true && every !== null && every > 0 && unit) return `every ${every === 1 ? "" : `${every} `}${unit.replace(/s$/i, "")}${every === 1 ? "" : "s"}`;
const once = iso(s.run_at);
if (once) return `once, ${once.slice(0, 16).replace("T", " ")}`;
return "";
}
/** Pure: `…/schedules` — the tasks that run on their own (a restart every night, a backup every Sunday). */
export function parseSchedules(raw: unknown): FragnetSchedule[] {
const out: FragnetSchedule[] = [];
@@ -249,9 +266,7 @@ export function parseSchedules(raw: unknown): FragnetSchedule[] {
const id = num(s.id);
const name = str(s.name);
if (id === null || !name) continue;
const c = obj(s.cron);
const cron = [c.minute, c.hour, c.day_of_month, c.month, c.day_of_week].map((x) => (typeof x === "string" || typeof x === "number" ? String(x) : "*")).join(" ");
out.push({ id, name, cron, active: s.is_active !== false, processing: s.is_processing === true, onlyWhenOnline: s.only_when_online === true, lastRunAt: iso(s.last_run_at), nextRunAt: iso(s.next_run_at) });
out.push({ id, name, cron: whenItRuns(s), active: s.is_active !== false, processing: s.is_processing === true, onlyWhenOnline: s.only_when_online === true, lastRunAt: iso(s.last_run_at), nextRunAt: iso(s.next_run_at) });
}
return out;
}