diff --git a/README.md b/README.md
index 23664c3..7e55246 100644
--- a/README.md
+++ b/README.md
@@ -34,12 +34,13 @@ A Jobindex query is its own syntax: words are OR, `"a b"` is a phrase, `+word` i
## The tabs
-Two tabs, and a cog for settings.
+Three tabs, and a cog for settings.
| | |
|---|---|
| **Roles** | newsdesk's feed: a filter rail (Show read, Best first or Newest first, first seen, tags, more filters), the open roles with company, place, age, tags and a summary, votes (▲ like ● neither way ▼ pass) and a Save button. A title opens the reader beside the list; on a phone it takes the screen. `j`/`k` move, `Enter` opens, `/` searches |
| **Applications** | the saved roles and their status, each change recorded as an event |
+| **Watchlist** | the companies whose board the app cannot read, for going through their careers pages by hand: Yes or No marks whether one is worth checking (a filter shows the unrated, the yes, the no or all), the careers page opens in a new tab and notes when, and a missing or wrong link is set in the row. A company whose board is failing is listed too. Separate from the affinity a search agent has |
The cog opens `/settings`: a rail of pages on the left, the page beside it, sticky so Runs is one click away however long the company list gets. On a phone the rail is a strip under the header.
diff --git a/app/models.py b/app/models.py
index 420efc2..119adfc 100644
--- a/app/models.py
+++ b/app/models.py
@@ -934,12 +934,14 @@ class Company(Model):
#: The name `ats` knows the company by, the `acme` of acme.teamtailor.com;
#: "" where discovery found none. Kept for a host no parser reads yet.
ats_slug: str = ""
+ #: The Watchlist's rating, global and not an agent's: None not yet rated,
+ #: 1 worth checking by hand, 0 not.
+ watch: int | None = None
+ #: When the careers page was last opened from the Watchlist; "" never.
+ careers_opened_at: str = ""
#: Why the company is read by hand, one of `HAND_REASONS`; "" when it is
#: not on that list.
hand_reason: str = ""
- #: When a person last looked at its careers page, an ISO timestamp; ""
- #: for never.
- checked_at: str = ""
created_at: str
updated_at: str
diff --git a/app/static/agents.js b/app/static/agents.js
index dc630d2..611a714 100644
--- a/app/static/agents.js
+++ b/app/static/agents.js
@@ -198,21 +198,25 @@
}
// The Where block in words, one sentence of the lines a role may match,
- // with the one-of rows among them since they are the same group: "Roles in
- // Denmark, in Malmö, Lund or Helsingborg, or remote within Europe."
+ // with the one-of rows among them since they are the same group: "Keeps
+ // roles anywhere in Denmark, in Malmö, Lund or Helsingborg, or remote within
+ // Europe, and leaves out the rest." The lines add up, which the first
+ // wording ("Roles in ...") left the owner to guess.
function whereSentence(where, others) {
const parts = [];
- if (where.countries) parts.push(phrase(where.countries));
+ if (where.countries) parts.push(`anywhere ${phrase(where.countries)}`);
if (where.places) parts.push(phrase(where.places));
if (where.remote) parts.push(where.europe ? "remote within Europe" : "remote");
parts.push(...others.map(phrase));
if (!parts.length) return "";
- return `Roles ${parts.length < 2 ? parts[0] : `${parts.slice(0, -1).join(", ")}, or ${parts[parts.length - 1]}`}.`;
+ const list = parts.length < 2 ? parts[0] : `${parts.slice(0, -1).join(", ")}, or ${parts[parts.length - 1]}`;
+ return `Keeps roles ${list}, and leaves out the rest.`;
}
// The gates in words: where a role may be, then what it must meet, then
- // what lifts it. "Roles in Denmark, or remote within Europe. Only roles
- // with seniority senior. Prefers hybrid."
+ // what lifts it. "Keeps roles anywhere in Denmark, or remote within Europe,
+ // and leaves out the rest. Only roles with seniority senior. Prefers
+ // hybrid."
function rulesLine(gates) {
const { where, rest } = distribute(gates);
const of = (mode) => rest.filter((g) => g.mode === mode);
@@ -604,7 +608,7 @@
const view = () => {
offerScope();
$("#a-gates", f).value = JSON.stringify(gates(), null, 2);
- $("#a-where-sum", f).textContent = rulesLine(gates()) || "Roles anywhere.";
+ $("#a-where-sum", f).textContent = rulesLine(gates()) || "Keeps roles anywhere.";
};
view();
diff --git a/app/static/app.css b/app/static/app.css
index 49ebaeb..4766423 100644
--- a/app/static/app.css
+++ b/app/static/app.css
@@ -1,6 +1,6 @@
/* The whole stylesheet: the boilerplate's, with roledesk's palette in the
* custom properties (a quiet UI face and newsdesk's teal signal colour), the
- * frame (a top bar of two tabs and a cog, the settings rail), roledesk's
+ * frame (a top bar of three tabs and a cog, the settings rail), roledesk's
* own pages, and at the bottom the phone: a width query for the layout and a
* pointer query for the sizes, after newsdesk and health. No build step.
*
@@ -477,11 +477,11 @@ body[data-rail="shut"] #rail { display: none; }
/* Reading opens a third column and the shell goes full width: the list keeps
a narrow lane on the left, the role takes the rest. */
body[data-reader="open"] .shell {
- grid-template-columns: 15rem 21rem minmax(0, 1fr);
+ grid-template-columns: 15rem 29rem minmax(0, 1fr);
max-width: none; gap: 1.2rem;
}
body[data-reader="open"][data-rail="shut"] .shell {
- grid-template-columns: 21rem minmax(0, 1fr);
+ grid-template-columns: 29rem minmax(0, 1fr);
}
/* -- the rail -- */
@@ -842,12 +842,13 @@ tr.muted { opacity: .55; }
padding: 1.6rem 2rem 4rem;
overflow-wrap: anywhere;
}
-/* ~68 characters a line at the reading size -- past that the eye loses the
- start of the next line and has to hunt for it. */
-.reader-body > * { max-width: 36rem; margin-inline: auto; }
+/* ~90 characters a line at the reading size: newsdesk's 36rem wrapped a
+ posting's short lines and lists too early. */
+.reader-body > * { max-width: 48rem; margin-inline: auto; }
.reader-meta { margin-top: 0; }
.reader-meta b { font-weight: 600; color: var(--dim); }
+.reader-meta .reader-careers { color: var(--dim); }
.reader-meta .affinity { font-size: .85rem; }
.reader-meta .affinity:empty { display: none; }
@@ -1339,3 +1340,21 @@ table.list select { padding: .25rem .4rem; }
.affinity button { min-width: 2.75rem; }
.check input { width: 1.25rem; height: 1.25rem; }
}
+
+/* Three tabs and the cog, at 390px: the phone block's padding and size leave
+ the bar 37px too wide, and a nowrap bar that is too wide scrolls the whole
+ page sideways. Tighter tabs, still touch-high (see the coarse block). */
+@media (max-width: 640px) {
+ .top { gap: .4rem; }
+ .top nav a { padding-inline: .25rem; font-size: .9rem; }
+ .top nav a.icon { padding-inline: .55rem; }
+}
+/* On Roles the search field is what gives way, not the tabs: the nav keeps
+ the width its tabs need and the field takes what is left. */
+@media (max-width: 640px) {
+ .top:has(#search) nav { flex: 0 0 auto; }
+ .top:has(#search) nav a:not(.icon) { padding-inline: .2rem; }
+ /* Which leaves the field a few letters wide, so while it is typed in it
+ takes the bar and the tabs step aside; they are back when it is left. */
+ .top:has(#search:focus) nav a:not(.icon), .top:has(#search:focus) desk-queue { display: none; }
+}
diff --git a/app/static/roles.js b/app/static/roles.js
index 34a16b8..4cb3b05 100644
--- a/app/static/roles.js
+++ b/app/static/roles.js
@@ -798,6 +798,7 @@
: text ? paragraphs(text)
: `
${r.company ? `${esc(r.company)}` : ""}
+ ${careers ? `Careers ↗` : ""}
${r.place ? `${esc(r.place)}` : ""}
${r.first_seen ? `${ago(r.first_seen)}` : ""}
diff --git a/app/static/watchlist.js b/app/static/watchlist.js
new file mode 100644
index 0000000..92a896e
--- /dev/null
+++ b/app/static/watchlist.js
@@ -0,0 +1,252 @@
+/* The Watchlist tab: the companies the app cannot read a board of, for
+ * going through their careers pages by hand.
+ *
+ * The list is app.js's shared company list (`/api/companies`), narrowed to
+ * the rule the "Not readable yet" filter of Company boards uses (no board
+ * subscription, not from a search), plus every company whose board is
+ * failing. The rating (`watch`: null unrated, 1 yes, 0 no) is global, not a
+ * search agent's affinity, and is set with `POST .../watch`. Opening the
+ * careers page stamps `careers_opened_at` (`POST .../opened`), so the row can
+ * say when, and the On the list filter sorts what was opened longest ago
+ * first. The filter is remembered per browser, and opens on Unrated.
+ */
+(function () {
+ "use strict";
+
+ const { api, count, debounce, safeUrl, companies, loadCompanies } = window;
+ const $ = (sel, root = document) => root.querySelector(sel);
+
+ const FILTER = "roledesk.watchlist";
+ const FILTERS = [
+ ["unrated", "Unrated"], ["yes", "On the list"], ["no", "Not on the list"], ["all", "All"],
+ ];
+ const DAY = 24 * 60 * 60 * 1000;
+
+ /** The key of the row whose careers link editor is open, or null. */
+ let editing = null;
+
+ function savedFilter() {
+ try {
+ const value = localStorage.getItem(FILTER);
+ return FILTERS.some(([f]) => f === value) ? value : "unrated";
+ } catch (err) {
+ return "unrated";
+ }
+ }
+
+ function saveFilter(value) {
+ try { localStorage.setItem(FILTER, value); } catch (err) { /* not remembered */ }
+ }
+
+ /** The companies the tab is about, before any filter. */
+ function watched() {
+ return [...companies.values()].filter(
+ (c) => (c.subscription_id == null && !c.from_search) || c.failing_since);
+ }
+
+ function matchesFilter(company, filter) {
+ switch (filter) {
+ case "unrated": return company.watch == null;
+ case "yes": return company.watch === 1;
+ case "no": return company.watch === 0;
+ default: return true;
+ }
+ }
+
+ function ago(iso) {
+ if (!iso) return "not opened yet";
+ const days = Math.floor((Date.now() - new Date(iso).getTime()) / DAY);
+ if (Number.isNaN(days)) return "not opened yet";
+ if (days < 1) return "opened today";
+ return `opened ${count(days, "day")} ago`;
+ }
+
+ /** Where the link goes: the careers page, else the company's own site. */
+ function target(company) {
+ const careers = safeUrl(company.careers_url);
+ if (careers) return { url: careers, label: "Careers page" };
+ const site = company.domain ? safeUrl(`https://${company.domain}`) : "";
+ return site ? { url: site, label: "Website" } : null;
+ }
+
+ async function rate(company, watch, rerender) {
+ try {
+ const updated = await api(`/api/companies/${encodeURIComponent(company.key)}/watch`, {
+ method: "POST", body: { watch },
+ });
+ company.watch = updated.watch;
+ } catch (err) {
+ return;
+ }
+ rerender();
+ }
+
+ /** Yes and No, in `.affinity`'s look; pressing the pressed one clears it. */
+ function ratingControl(company, rerender) {
+ const span = document.createElement("span");
+ span.className = "affinity";
+ span.setAttribute("role", "group");
+ span.setAttribute("aria-label", `Watch ${company.name}`);
+ for (const [value, label, watch] of [[1, "Yes", true], [-1, "No", false]]) {
+ const pressed = company.watch === (watch ? 1 : 0);
+ const button = document.createElement("button");
+ button.type = "button";
+ button.dataset.value = String(value);
+ button.textContent = label;
+ button.setAttribute("aria-pressed", String(pressed));
+ button.addEventListener("click", () => rate(company, pressed ? null : watch, rerender));
+ span.appendChild(button);
+ }
+ return span;
+ }
+
+ function subLine(company, rerender) {
+ const sub = document.createElement("span");
+ sub.className = "sub";
+ const badge = document.createElement("span");
+ badge.className = "badge";
+ badge.textContent = company.board || company.ats || "board not found";
+ sub.appendChild(badge);
+ const place = [company.city, (company.country || "").toUpperCase()].filter(Boolean).join(", ");
+ if (place) sub.append(` ${place}`);
+ if (company.failing_since) {
+ const failing = document.createElement("span");
+ failing.className = "failing";
+ failing.textContent = `board failing since ${company.failing_since.slice(0, 10)}`;
+ sub.append(" · ");
+ sub.appendChild(failing);
+ }
+ sub.append(" · ");
+ const where = target(company);
+ if (where) {
+ const link = document.createElement("a");
+ link.href = where.url;
+ link.target = "_blank";
+ link.rel = "noopener noreferrer";
+ link.textContent = where.label;
+ link.addEventListener("click", () => opened(company, rerender));
+ sub.appendChild(link);
+ sub.append(` · ${ago(company.careers_opened_at)} `);
+ }
+ const edit = document.createElement("button");
+ edit.type = "button";
+ edit.className = "linky";
+ edit.textContent = company.careers_url ? "Edit link" : "Add careers page";
+ edit.setAttribute("aria-expanded", String(editing === company.key));
+ edit.addEventListener("click", () => {
+ editing = editing === company.key ? null : company.key;
+ rerender();
+ });
+ sub.appendChild(edit);
+ return sub;
+ }
+
+ /** The link was followed: stamp it. The new tab is already open, so this
+ only updates the row, and only the stamp, so the row does not jump. */
+ async function opened(company, rerender) {
+ try {
+ const updated = await api(`/api/companies/${encodeURIComponent(company.key)}/opened`,
+ { method: "POST" });
+ company.careers_opened_at = updated.careers_opened_at;
+ } catch (err) {
+ return;
+ }
+ rerender();
+ }
+
+ function linkEditor(company, rerender) {
+ const form = document.createElement("form");
+ form.className = "board-edit";
+ form.autocomplete = "off";
+ const input = document.createElement("input");
+ input.type = "url";
+ input.spellcheck = false;
+ input.placeholder = "https://";
+ input.value = company.careers_url || "";
+ input.setAttribute("aria-label", `${company.name}'s careers page`);
+ const save = document.createElement("button");
+ save.type = "submit";
+ save.textContent = "Save";
+ const cancel = document.createElement("button");
+ cancel.type = "button";
+ cancel.className = "linky";
+ cancel.textContent = "Cancel";
+ cancel.addEventListener("click", () => { editing = null; rerender(); });
+ form.append(input, save, cancel);
+ form.addEventListener("submit", async (event) => {
+ event.preventDefault();
+ save.disabled = true;
+ try {
+ const updated = await api(`/api/companies/${encodeURIComponent(company.key)}/careers`,
+ { method: "POST", body: { careers_url: input.value.trim() } });
+ company.careers_url = updated.careers_url;
+ editing = null;
+ rerender();
+ } catch (err) {
+ save.disabled = false;
+ }
+ });
+ return form;
+ }
+
+ /** The filter's options with their counts, kept on the chosen one. */
+ function drawFilter(all) {
+ const select = $("#w-filter");
+ const chosen = select.value || savedFilter();
+ select.replaceChildren();
+ for (const [value, label] of FILTERS) {
+ const option = document.createElement("option");
+ option.value = value;
+ option.textContent = `${label} (${all.filter((c) => matchesFilter(c, value)).length})`;
+ select.appendChild(option);
+ }
+ select.value = chosen;
+ }
+
+ function render() {
+ const all = watched();
+ drawFilter(all);
+ const q = $("#w-q").value.trim().toLowerCase();
+ const filter = $("#w-filter").value;
+ const rows = all
+ .filter((c) => !q || c.name.toLowerCase().includes(q)
+ || (c.board || c.ats || "").includes(q) || (c.country || "").toLowerCase() === q)
+ .filter((c) => matchesFilter(c, filter));
+ // Overdue first on the list, never opened on top (the empty stamp sorts
+ // before any date); every other filter is by name.
+ rows.sort((a, b) => (filter === "yes"
+ ? a.careers_opened_at.localeCompare(b.careers_opened_at) : 0)
+ || a.name.localeCompare(b.name));
+ const body = $("#watchlist-list");
+ body.replaceChildren();
+ for (const company of rows) {
+ const row = document.createElement("div");
+ row.className = "crow";
+ const name = document.createElement("span");
+ name.className = "name";
+ name.textContent = company.name;
+ row.appendChild(name);
+ row.appendChild(ratingControl(company, render));
+ row.appendChild(subLine(company, render));
+ if (editing === company.key) row.appendChild(linkEditor(company, render));
+ body.appendChild(row);
+ }
+ $("#watchlist-count").textContent = count(rows.length, "company", "companies");
+ }
+
+ document.addEventListener("DOMContentLoaded", async () => {
+ if (!$("#watchlist-list")) return;
+ try {
+ await loadCompanies();
+ } catch (err) {
+ return;
+ }
+ $("#w-filter").value = savedFilter();
+ render();
+ $("#w-q").addEventListener("input", debounce(render, 150));
+ $("#w-filter").addEventListener("change", () => {
+ saveFilter($("#w-filter").value);
+ render();
+ });
+ });
+})();
diff --git a/app/storage/schema.py b/app/storage/schema.py
index c63194d..ff3353c 100644
--- a/app/storage/schema.py
+++ b/app/storage/schema.py
@@ -107,8 +107,11 @@ CREATE TABLE IF NOT EXISTS role_tags (
-- yet. country is an ISO code and city the head office's. ats_slug is the
-- name that host knows the company by (the acme of acme.teamtailor.com),
-- '' where its URL carries none, kept for the parser written later.
+-- watch is the Watchlist's rating, global and not an agent's: NULL unrated, 1
+-- worth checking by hand, 0 not; careers_opened_at when its careers page was
+-- last opened from there, which is also when a person last looked at it.
-- hand_reason is why a person reads the careers page (models.HAND_REASONS),
--- '' when nobody has to, and checked_at when one last did, '' for never.
+-- '' when nobody has to.
CREATE TABLE IF NOT EXISTS companies (
key TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -122,8 +125,9 @@ CREATE TABLE IF NOT EXISTS companies (
country TEXT NOT NULL DEFAULT '',
city TEXT NOT NULL DEFAULT '',
ats_slug TEXT NOT NULL DEFAULT '',
- hand_reason TEXT NOT NULL DEFAULT '',
- checked_at TEXT NOT NULL DEFAULT ''
+ watch INTEGER CHECK (watch IN (0, 1)),
+ careers_opened_at TEXT NOT NULL DEFAULT '',
+ hand_reason TEXT NOT NULL DEFAULT ''
);
-- The targets desk's runner hands to plugins. newsdesk's shape, with its two
@@ -428,10 +432,19 @@ ALTER TABLE agents DROP COLUMN intent_key;
ALTER TABLE agents DROP COLUMN intent_vec;
ALTER TABLE scores ADD COLUMN prompt TEXT NOT NULL DEFAULT '';
"""),
- (15, "companies.hand_reason and checked_at: the companies read by hand are a list "
- "with a reason and a date last looked at", """
+ # The Watchlist's own rating, global and apart from an agent's affinity:
+ # NULL not yet rated, 1 worth checking by hand, 0 not. Every company
+ # starts unrated.
+ (15, "companies.watch and careers_opened_at: the Watchlist's rating and "
+ "when its careers page was last opened", """
+ALTER TABLE companies ADD COLUMN watch INTEGER CHECK (watch IN (0, 1));
+ALTER TABLE companies ADD COLUMN careers_opened_at TEXT NOT NULL DEFAULT '';
+"""),
+ # Why a person reads the company's careers page by hand, one of
+ # models.HAND_REASONS; '' when nobody has to. When it was last looked at
+ # is careers_opened_at.
+ (16, "companies.hand_reason: why a company is read by hand", """
ALTER TABLE companies ADD COLUMN hand_reason TEXT NOT NULL DEFAULT '';
-ALTER TABLE companies ADD COLUMN checked_at TEXT NOT NULL DEFAULT '';
"""),
)
diff --git a/app/storage/store.py b/app/storage/store.py
index 5a5adea..c3f880e 100644
--- a/app/storage/store.py
+++ b/app/storage/store.py
@@ -94,7 +94,7 @@ _EXCERPT_SOURCE = "COALESCE(NULLIF(roles.summary, ''), roles.description)"
_EXCERPT_RAW = 240
_COMPANY_FIELDS = ("name", "domain", "status", "careers_url", "notes", "ats", "country", "city",
- "ats_slug", "hand_reason", "checked_at")
+ "ats_slug", "watch", "careers_opened_at", "hand_reason")
#: A company as the store serves it: the row and the asked-for agent's affinity.
_COMPANY_SELECT = """SELECT c.*, COALESCE(ac.affinity, 0) AS affinity FROM companies c
@@ -496,10 +496,11 @@ class Store:
"""Newest first by `posted_at`. `company` and `place` are
case-insensitive substrings of the columns a board wrote — not the
key, so a search does not have to know the exact slug a company folds
- to. `q` is matched word by word against `title`; a role must match
- every word. `function` and `remote` match a gate column exactly.
- `days` keeps only roles posted within that many days of now. `pay`
- (a key of `PAY`) filters on `salary_state`.
+ to. `q` is matched word by word against `title` and `company`; a
+ role must match every word in one or the other. `function` and
+ `remote` match a gate column exactly. `days` keeps only roles posted
+ within that many days of now. `pay` (a key of `PAY`) filters on
+ `salary_state`.
`agent` says whose votes, hidden companies and scores are meant. Each
row carries that agent's `vote` and `voted_at`; `judged` (a key of
@@ -653,8 +654,8 @@ class Store:
where.append("posted_at >= ?")
params.append(_iso(self.clock() - timedelta(days=days)))
for word in (q or "").split():
- where.append("title LIKE ? ESCAPE '\\'")
- params.append(_like(word))
+ where.append("(title LIKE ? ESCAPE '\\' OR company LIKE ? ESCAPE '\\')")
+ params += [_like(word)] * 2
if judged:
if judged not in JUDGED:
raise ValueError(f"judged is {', '.join(JUDGED)}, not {judged!r}")
@@ -1162,8 +1163,8 @@ class Store:
def add_company(self, name: str, *, key: str = "", domain: str = "",
status: str = "researching", careers_url: str = "",
notes: str = "", ats: str = "", country: str = "",
- city: str = "", ats_slug: str = "", hand_reason: str = "",
- checked_at: str = "") -> Company:
+ city: str = "", ats_slug: str = "",
+ hand_reason: str = "") -> Company:
"""Raises ValueError on a key already taken or a `hand_reason` outside
`HAND_REASONS`."""
name = name.strip()
@@ -1176,8 +1177,7 @@ class Store:
self._insert_company(conn, key, name, {
"domain": domain, "status": status, "careers_url": careers_url,
"notes": notes, "ats": ats, "country": country, "city": city,
- "ats_slug": ats_slug, "hand_reason": hand_reason,
- "checked_at": checked_at})
+ "ats_slug": ats_slug, "hand_reason": hand_reason})
except sqlite3.IntegrityError as exc:
raise ValueError(f"company {key!r} already exists") from exc
return self._company(key)
diff --git a/app/templates/roles.html b/app/templates/roles.html
index 44a67d7..cd1e6dd 100644
--- a/app/templates/roles.html
+++ b/app/templates/roles.html
@@ -28,7 +28,7 @@
-
{% endblock %}
diff --git a/app/templates/settings/agents.html b/app/templates/settings/agents.html
index b07a7f8..784cb42 100644
--- a/app/templates/settings/agents.html
+++ b/app/templates/settings/agents.html
@@ -28,18 +28,18 @@