Per-agent ranking: votes, affinity and a taste term; settings are three sub-tabs
Votes on roles and company affinity move to role_votes and agent_companies, one row per search agent, so two agents rank the same roles differently. The score gains taste, the cosine to mean(liked) - mean(passed) of the agent's votes, as newsdesk ranks articles. The API takes agent on roles, votes and companies and falls back to the default agent, the enabled one with the lowest id. Settings become Search agents (a list again, with New and Delete), Sources (job boards, company boards and runs with the message log, one section per plugin) and Account. Old paths answer 301 to their section. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
515d2250fc
commit
a0772519b3
28 files changed
+1461
-668
No files matched your search
+55
-9
@@ -1,11 +1,17 @@
|
||||
/* The Companies page: every company, its board, its open roles, its
|
||||
* affinity, following a new one, and pruning boards with nothing open in a
|
||||
* region.
|
||||
/* The Company boards section of Sources: every company, its board, its open
|
||||
* roles, its affinity, following a new one, and pruning boards with nothing
|
||||
* open in a region.
|
||||
*
|
||||
* The list is app.js's shared company list (`/api/companies`), already
|
||||
* joined with each company's board subscription — its id and whether it is
|
||||
* on — so nothing here fetches `/api/sources` as well. The affinity buttons
|
||||
* are `affinityControl`, the same ones the Roles tab and the read page draw.
|
||||
*
|
||||
* Liked and hidden are per search agent, so the `#c-agent` select above the
|
||||
* list says whose the list shows and whose the buttons set. It opens on the
|
||||
* server's default, the enabled agent with the lowest id; with no agent at
|
||||
* all there is nothing to like, and the section says so instead of drawing
|
||||
* the buttons.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -13,6 +19,31 @@
|
||||
const { api, count, debounce, companies, loadCompanies, affinityControl } = window;
|
||||
const $ = (sel, root = document) => root.querySelector(sel);
|
||||
|
||||
/** @type {object[]} the search agents, by id */
|
||||
let agents = [];
|
||||
|
||||
/** The id in `#c-agent`, or null while there is no agent to pick. */
|
||||
function agentId() {
|
||||
const value = $("#c-agent").value;
|
||||
return value ? Number(value) : null;
|
||||
}
|
||||
|
||||
async function loadAgents() {
|
||||
agents = (await api("/api/agents")).sort((a, b) => a.id - b.id);
|
||||
const select = $("#c-agent");
|
||||
select.replaceChildren();
|
||||
for (const a of agents) {
|
||||
const option = document.createElement("option");
|
||||
option.value = String(a.id);
|
||||
option.textContent = a.name;
|
||||
select.appendChild(option);
|
||||
}
|
||||
const first = agents.find((a) => a.enabled) || agents[0];
|
||||
if (first) select.value = String(first.id);
|
||||
select.closest("label").hidden = !first;
|
||||
$("#c-no-agent").hidden = Boolean(first);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- the list
|
||||
|
||||
function subLine(company) {
|
||||
@@ -24,7 +55,7 @@
|
||||
badge.textContent = company.board;
|
||||
sub.appendChild(badge);
|
||||
} else {
|
||||
sub.append("from searches");
|
||||
sub.append("from job boards");
|
||||
}
|
||||
sub.append(` · ${count(company.open_roles, "open role")}`);
|
||||
return sub;
|
||||
@@ -88,7 +119,10 @@
|
||||
row.appendChild(link);
|
||||
const switchBox = onSwitch(company, render);
|
||||
if (switchBox) row.appendChild(switchBox);
|
||||
row.appendChild(affinityControl(company.key, company.affinity, async () => render()));
|
||||
const agent = agentId();
|
||||
if (agent != null) {
|
||||
row.appendChild(affinityControl(company.key, company.affinity, async () => render(), agent));
|
||||
}
|
||||
row.appendChild(subLine(company));
|
||||
body.appendChild(row);
|
||||
}
|
||||
@@ -111,7 +145,7 @@
|
||||
method: "POST",
|
||||
body: { board, name: $("#b-name").value.trim() },
|
||||
});
|
||||
await loadCompanies();
|
||||
await loadCompanies(agentId());
|
||||
render();
|
||||
$("#board-form").reset();
|
||||
status.textContent = `Following ${result.source.label}: `
|
||||
@@ -167,7 +201,7 @@
|
||||
+ `closed ${count(result.roles_closed, "role")}. ${result.boards_left} boards are on.`;
|
||||
$("#prune-list").replaceChildren();
|
||||
$("#p-apply").textContent = "Switch off these boards";
|
||||
await loadCompanies();
|
||||
await loadCompanies(agentId());
|
||||
render();
|
||||
} catch (err) {
|
||||
$("#p-apply").disabled = false;
|
||||
@@ -176,15 +210,27 @@
|
||||
|
||||
// -------------------------------------------------------------------- init
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
async function switchAgent() {
|
||||
try {
|
||||
await loadCompanies();
|
||||
await loadCompanies(agentId());
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
render();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
if (!$("#companies-list")) return;
|
||||
try {
|
||||
await loadAgents();
|
||||
await loadCompanies(agentId());
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
render();
|
||||
$("#c-q").addEventListener("input", debounce(render, 150));
|
||||
$("#c-filter").addEventListener("change", render);
|
||||
$("#c-agent").addEventListener("change", switchAgent);
|
||||
$("#board-form").addEventListener("submit", addBoard);
|
||||
$("#prune-form").addEventListener("submit", previewPrune);
|
||||
$("#p-apply").addEventListener("click", applyPrune);
|
||||
|
||||
Reference in new issue
Block a user