Show and set each board's reach on the Companies list, list the readers' declarations on Sources, and document filtering at the source
A company row says what a pull asks its board for; its editor sets the board's own reach (the agents', all roles, or countries and remote) through /api/sources/{id}/reach. /api/readers lists each reader's listing, text, filters, places and robots decision, folded under the Follow form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3462a4abe7
commit
dafca5435e
8 files changed
+333
-8
No files matched your search
+63
-1
@@ -17,6 +17,11 @@
|
||||
* into the Follow form's `#b-host`, and a slug. Saving posts to
|
||||
* `/api/companies/{key}/board`, which reads the board once before keeping
|
||||
* it; Detach stops reading it and keeps the company.
|
||||
*
|
||||
* A row with a board says what a pull asks it for ("reads DK, SE · agents",
|
||||
* `reach` from app/jobs/reach.py), and its editor has a second line that
|
||||
* sets the board's own reach: the agents', all roles, or its own countries
|
||||
* and remote, posted to `/api/sources/{id}/reach`.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -90,6 +95,7 @@
|
||||
sub.appendChild(link);
|
||||
}
|
||||
sub.append(` · ${count(company.open_roles, "open role")}`);
|
||||
if (company.reach) sub.append(` · reads ${company.reach}`);
|
||||
if (company.failing_since) {
|
||||
// The board has failed on every pull since then; after 21 days its
|
||||
// roles close.
|
||||
@@ -199,6 +205,58 @@
|
||||
return form;
|
||||
}
|
||||
|
||||
/** The open row's reach editor, for a row with a board: the agents' reach,
|
||||
all roles, or the board's own countries and remote. */
|
||||
function reachEditor(company, rerender) {
|
||||
if (company.subscription_id == null) return null;
|
||||
const own = company.reach_params || {};
|
||||
const form = document.createElement("form");
|
||||
form.className = "board-edit";
|
||||
form.autocomplete = "off";
|
||||
const mode = document.createElement("select");
|
||||
mode.setAttribute("aria-label", `What ${company.name}'s board is asked for`);
|
||||
for (const [value, label] of [["agents", "Agents' reach"], ["all", "All roles"],
|
||||
["own", "These countries"]]) {
|
||||
mode.appendChild(new Option(label, value));
|
||||
}
|
||||
mode.value = own.reach === "all" ? "all" : (own.countries || own.remote != null ? "own" : "agents");
|
||||
const codes = document.createElement("input");
|
||||
codes.type = "text";
|
||||
codes.spellcheck = false;
|
||||
codes.placeholder = "DK SE";
|
||||
codes.value = (own.countries || []).join(" ");
|
||||
codes.setAttribute("aria-label", "Country codes");
|
||||
const remote = document.createElement("select");
|
||||
remote.setAttribute("aria-label", "Remote roles");
|
||||
remote.append(new Option("and remote", "yes"), new Option("no remote", "no"));
|
||||
remote.value = own.remote ? "yes" : "no";
|
||||
const save = document.createElement("button");
|
||||
save.type = "submit";
|
||||
save.textContent = "Set reach";
|
||||
const shown = () => { codes.hidden = remote.hidden = mode.value !== "own"; };
|
||||
mode.addEventListener("change", shown);
|
||||
shown();
|
||||
form.append(mode, codes, remote, save);
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
save.disabled = true;
|
||||
try {
|
||||
const result = await api(`/api/sources/${company.subscription_id}/reach`, {
|
||||
method: "POST",
|
||||
body: { mode: mode.value, countries: codes.value.split(/[\s,]+/).filter(Boolean),
|
||||
remote: remote.value === "yes" },
|
||||
});
|
||||
window.toast.info(`${company.name}: reads ${result.reach} from the next pull.`);
|
||||
editing = null;
|
||||
await loadCompanies(agentId());
|
||||
rerender();
|
||||
} catch (err) {
|
||||
save.disabled = false;
|
||||
}
|
||||
});
|
||||
return form;
|
||||
}
|
||||
|
||||
/** The board switch, or nothing for a company with no board:
|
||||
there is no subscription to switch. */
|
||||
function onSwitch(company, rerender) {
|
||||
@@ -274,7 +332,11 @@
|
||||
row.appendChild(affinityControl(company.key, company.affinity, async () => render(), agent));
|
||||
}
|
||||
row.appendChild(subLine(company, render));
|
||||
if (editing === company.key) row.appendChild(boardEditor(company, render));
|
||||
if (editing === company.key) {
|
||||
row.appendChild(boardEditor(company, render));
|
||||
const reach = reachEditor(company, render);
|
||||
if (reach) row.appendChild(reach);
|
||||
}
|
||||
body.appendChild(row);
|
||||
}
|
||||
const open = rows.reduce((sum, c) => sum + c.open_roles, 0);
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
*
|
||||
* It is also the page's first script, so it shows the one section of the
|
||||
* four the URL fragment names and marks it in the settings rail.
|
||||
*
|
||||
* Under the Follow form of Company boards, a fold lists what each reader
|
||||
* declares (`/api/readers`): how its list arrives, where the text is, what
|
||||
* it filters at the source, how it states places, and the robots.txt
|
||||
* decision taken when it was built.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -277,6 +282,44 @@
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------- readers
|
||||
|
||||
/** "country one, remote ids", or "none". */
|
||||
function filters(reader) {
|
||||
const shown = Object.entries(reader.filters).map(([name, how]) => `${name} ${how}`);
|
||||
return shown.length ? shown.join(", ") : "none";
|
||||
}
|
||||
|
||||
function renderReaders(readers) {
|
||||
const fold = document.createElement("details");
|
||||
fold.className = "prune";
|
||||
fold.id = "readers";
|
||||
const summary = document.createElement("summary");
|
||||
summary.textContent = `What each reader does (${readers.length})`;
|
||||
const list = document.createElement("div");
|
||||
list.className = "srows";
|
||||
for (const reader of readers) {
|
||||
const row = document.createElement("div");
|
||||
row.className = "srow";
|
||||
const name = document.createElement("span");
|
||||
name.className = "name";
|
||||
const label = document.createElement("span");
|
||||
label.textContent = reader.label;
|
||||
const scope = document.createElement("span");
|
||||
scope.className = "badge";
|
||||
scope.textContent = reader.scope === "search" ? "job board" : "company board";
|
||||
name.append(label, scope);
|
||||
const sub = document.createElement("span");
|
||||
sub.className = "sub";
|
||||
sub.textContent = [`list ${reader.listing}`, `text ${reader.text}`,
|
||||
`filters ${filters(reader)}`, `places ${reader.places}`, reader.robots].join(" · ");
|
||||
row.append(name, sub);
|
||||
list.appendChild(row);
|
||||
}
|
||||
fold.append(summary, list);
|
||||
$("#board-form").after(fold);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------ one section shown
|
||||
|
||||
// Sources shows one section: the one the fragment names or contains, or the
|
||||
@@ -317,6 +360,7 @@
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
if (!$("#searches-list")) return;
|
||||
if ($("#board-form")) api("/api/readers").then(renderReaders, () => {});
|
||||
try {
|
||||
await load();
|
||||
} catch (err) {
|
||||
|
||||
Reference in new issue
Block a user