Make the agent's scope a line of its own: Only roles in Europe, chosen countries or Everywhere, read and written as the require gate on country
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1c7bc72198
commit
888586c29b
5 files changed
+179
-95
No files matched your search
+49
-28
@@ -33,11 +33,8 @@
|
|||||||
// best `summarise_top` at `summarise_min` or more a summary.
|
// best `summarise_top` at `summarise_min` or more a summary.
|
||||||
const DEFAULT_LIMITS = { extract_top: 500, extract_min: 0.55, summarise_top: 30, summarise_min: 0.65 };
|
const DEFAULT_LIMITS = { extract_top: 500, extract_min: 0.55, summarise_top: 30, summarise_min: 0.65 };
|
||||||
const NEW = "new";
|
const NEW = "new";
|
||||||
// Europe as the starter agents in config.example.yaml spell it: the EEA,
|
// Europe as the starter agents spell it (static/remote.js).
|
||||||
// the UK and Switzerland, and EU for a role open anywhere in Europe.
|
const EUROPE = rh.EUROPE;
|
||||||
const EUROPE = ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR",
|
|
||||||
"HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE",
|
|
||||||
"IS", "LI", "NO", "GB", "CH", "EU"];
|
|
||||||
const FIELDS = ["place", "country", "remote", "remote_from", "seniority", "function", "salary_min",
|
const FIELDS = ["place", "country", "remote", "remote_from", "seniority", "function", "salary_min",
|
||||||
"currency", "permit", "languages", "company"];
|
"currency", "permit", "languages", "company"];
|
||||||
const MODES = [["require", "must"], ["any", "one of"], ["prefer", "prefer"]];
|
const MODES = [["require", "must"], ["any", "one of"], ["prefer", "prefer"]];
|
||||||
@@ -224,24 +221,35 @@
|
|||||||
return `with ${gate.field.replace("_", " ")} ${values.join(", ")}`;
|
return `with ${gate.field.replace("_", " ")} ${values.join(", ")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The Where block in words, one sentence of the lines a role may match,
|
// The scope of the Where block in words: "Within Europe", "Within Denmark or
|
||||||
// with the one-of rows among them since they are the same group: "Keeps
|
// Sweden", "Everywhere".
|
||||||
// roles anywhere in Denmark, in Malmö, Lund or Helsingborg, or remote from
|
function scopeWords(scope) {
|
||||||
// Denmark, Sweden or Germany, and leaves out the rest." The lines add up, which the first
|
if (scope.kind === "everywhere") return "Everywhere";
|
||||||
// wording ("Roles in ...") left the owner to guess.
|
if (scope.kind === "europe") return "Within Europe";
|
||||||
|
return `Within ${phrase({ field: "country", values: scope.values }).replace(/^in /, "")}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Where block in words, one sentence led by its scope, then the lines a
|
||||||
|
// role may match, with the one-of rows among them since they are the same
|
||||||
|
// group: "Within Europe: keeps roles anywhere in Denmark, in Malmö, Lund or
|
||||||
|
// Helsingborg, or remote, and leaves out the rest." The lines add up, which
|
||||||
|
// the first wording ("Roles in ...") left the owner to guess.
|
||||||
function whereSentence(where, others) {
|
function whereSentence(where, others) {
|
||||||
const parts = [];
|
const parts = [];
|
||||||
if (where.countries) parts.push(`anywhere ${phrase(where.countries)}`);
|
if (where.countries) parts.push(`anywhere ${phrase(where.countries)}`);
|
||||||
if (where.places) parts.push(phrase(where.places));
|
if (where.places) parts.push(phrase(where.places));
|
||||||
if (where.remote && where.remote.values.length) parts.push(rh.remoteSentence(where.remote.values, placeLabel));
|
if (where.remote.mode === "scope") parts.push("remote");
|
||||||
|
if (where.remote.mode === "from" && where.remote.values.length) {
|
||||||
|
parts.push(rh.remoteSentence(where.remote.values, placeLabel));
|
||||||
|
}
|
||||||
parts.push(...others.map(phrase));
|
parts.push(...others.map(phrase));
|
||||||
if (!parts.length) return "";
|
if (!parts.length) return where.scope.kind === "everywhere" ? "" : `${scopeWords(where.scope)}: keeps every role.`;
|
||||||
const list = 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.`;
|
return `${scopeWords(where.scope)}: keeps roles ${list}, and leaves out the rest.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The gates in words: where a role may be, then what it must meet, then
|
// The gates in words: where a role may be, then what it must meet, then
|
||||||
// what lifts it. "Keeps roles anywhere in Denmark, or remote from anywhere,
|
// what lifts it. "Within Europe: keeps roles anywhere in Denmark, or remote,
|
||||||
// and leaves out the rest. Only roles with seniority senior. Prefers
|
// and leaves out the rest. Only roles with seniority senior. Prefers
|
||||||
// hybrid."
|
// hybrid."
|
||||||
function rulesLine(gates) {
|
function rulesLine(gates) {
|
||||||
@@ -402,10 +410,10 @@
|
|||||||
return { node: chips.node, values: () => [...chips.list] };
|
return { node: chips.node, values: () => [...chips.list] };
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Remote, open to someone in": the values of a `remote_from` gate as chips,
|
// "Only when open to someone in": the values of a `remote_from` gate as
|
||||||
// picked from the place suggestions that a remote hire can live in:
|
// chips, picked from the place suggestions that a remote hire can live in:
|
||||||
// countries, regions and Anywhere. `values()` are the gate's values
|
// countries and regions. `values()` are the gate's values (`country:DK`),
|
||||||
// (`country:DK`, `anywhere`), the chips say them in words.
|
// the chips say them in words.
|
||||||
function remoteInput(values, onChange) {
|
function remoteInput(values, onChange) {
|
||||||
const root = el("div");
|
const root = el("div");
|
||||||
root.id = "a-remote-from";
|
root.id = "a-remote-from";
|
||||||
@@ -415,20 +423,15 @@
|
|||||||
const picks = [];
|
const picks = [];
|
||||||
for (const s of rows) {
|
for (const s of rows) {
|
||||||
const value = rh.fromSuggestion(s);
|
const value = rh.fromSuggestion(s);
|
||||||
if (value === null) continue;
|
if (value !== null) picks.push({ value, label: s.label, hint: s.kind });
|
||||||
picks.push(value === rh.ANYWHERE
|
|
||||||
? { value, label: "Anywhere" }
|
|
||||||
: { value, label: s.label, hint: s.kind });
|
|
||||||
}
|
}
|
||||||
const has = picks.some((p) => p.value === rh.ANYWHERE);
|
|
||||||
if (!has && rh.offersAnywhere(q)) picks.unshift({ value: rh.ANYWHERE, label: "Anywhere" });
|
|
||||||
return picks;
|
return picks;
|
||||||
},
|
},
|
||||||
onChange: (items) => {
|
onChange: (items) => {
|
||||||
items.forEach((i) => placeNames.set(i.value, i.label));
|
items.forEach((i) => placeNames.set(i.value, i.label));
|
||||||
onChange();
|
onChange();
|
||||||
},
|
},
|
||||||
placeholder: "Add a country, a region or Anywhere", label: "Remote, open to someone in",
|
placeholder: "Add a country or a region", label: "Remote, open to someone in",
|
||||||
});
|
});
|
||||||
chips.set(values.map((v) => ({ value: v, label: placeLabel(v) })));
|
chips.set(values.map((v) => ({ value: v, label: placeLabel(v) })));
|
||||||
return { node: root, values: () => chips.values().map((i) => i.value) };
|
return { node: root, values: () => chips.values().map((i) => i.value) };
|
||||||
@@ -574,14 +577,26 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { where, rest } = rh.distribute(row ? row.gates : []);
|
const { where, rest } = rh.distribute(row ? row.gates : []);
|
||||||
|
const scope = $("#a-scope", f);
|
||||||
|
scope.value = where.scope.kind;
|
||||||
|
const scoped = countryInput(where.scope.values);
|
||||||
const countries = countryInput(where.countries ? where.countries.values : []);
|
const countries = countryInput(where.countries ? where.countries.values : []);
|
||||||
const places = wordInput(where.places ? where.places.values : [], "Add a town");
|
const places = wordInput(where.places ? where.places.values : [], "Add a town");
|
||||||
const terms = wordInput(row ? row.fetch_terms || [] : [], "machine learning, data science");
|
const terms = wordInput(row ? row.fetch_terms || [] : [], "machine learning, data science");
|
||||||
$("#a-terms", f).replaceWith(terms.node);
|
$("#a-terms", f).replaceWith(terms.node);
|
||||||
|
$("#a-scope-countries", f).replaceWith(scoped.node);
|
||||||
$("#a-countries", f).replaceWith(countries.node);
|
$("#a-countries", f).replaceWith(countries.node);
|
||||||
$("#a-towns", f).replaceWith(places.node);
|
$("#a-towns", f).replaceWith(places.node);
|
||||||
const remoteFrom = remoteInput(where.remote ? where.remote.values : [], () => changed(f));
|
const remoteMode = $("#a-remote", f);
|
||||||
|
remoteMode.value = where.remote.mode;
|
||||||
|
const remoteFrom = remoteInput(where.remote.mode === "from" ? where.remote.values : [], () => changed(f));
|
||||||
$("#a-remote-from", f).replaceWith(remoteFrom.node);
|
$("#a-remote-from", f).replaceWith(remoteFrom.node);
|
||||||
|
// Only the pick that is on shows its chips.
|
||||||
|
const offer = () => {
|
||||||
|
scoped.node.hidden = scope.value !== "countries";
|
||||||
|
remoteFrom.node.hidden = remoteMode.value !== "from";
|
||||||
|
};
|
||||||
|
offer();
|
||||||
// The hybrid weight shows only when it is not the default; either way it
|
// The hybrid weight shows only when it is not the default; either way it
|
||||||
// is sent back as it came.
|
// is sent back as it came.
|
||||||
const hybridWeight = where.hybrid && where.hybrid.weight !== undefined ? where.hybrid.weight : HYBRID_WEIGHT;
|
const hybridWeight = where.hybrid && where.hybrid.weight !== undefined ? where.hybrid.weight : HYBRID_WEIGHT;
|
||||||
@@ -609,14 +624,19 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// The gates the Where block says, in the order the starter agents have
|
// The gates the Where block says, in the order the starter agents have
|
||||||
// them: the lines, then hybrid.
|
// them: the scope, the lines, then hybrid.
|
||||||
function whereGates() {
|
function whereGates() {
|
||||||
const out = [];
|
const out = [];
|
||||||
const within = countries.values();
|
const within = countries.values();
|
||||||
const towns = places.values();
|
const towns = places.values();
|
||||||
const from = remoteFrom.values();
|
const from = remoteFrom.values();
|
||||||
|
if (scope.value === "europe") out.push({ field: "country", values: rh.europeWith(within), mode: "require" });
|
||||||
|
if (scope.value === "countries" && scoped.values().length) {
|
||||||
|
out.push({ field: "country", values: scoped.values(), mode: "require" });
|
||||||
|
}
|
||||||
if (within.length) out.push({ field: "country", values: within, mode: "any" });
|
if (within.length) out.push({ field: "country", values: within, mode: "any" });
|
||||||
if (from.length) out.push({ field: "remote_from", values: from, mode: "any" });
|
if (remoteMode.value === "scope") out.push({ field: "remote", values: ["remote"], mode: "any" });
|
||||||
|
if (remoteMode.value === "from" && from.length) out.push({ field: "remote_from", values: from, mode: "any" });
|
||||||
if (towns.length) out.push({ field: "place", values: towns, mode: "any" });
|
if (towns.length) out.push({ field: "place", values: towns, mode: "any" });
|
||||||
if ($("#a-hybrid", f).checked) {
|
if ($("#a-hybrid", f).checked) {
|
||||||
out.push({ field: "remote", values: ["hybrid"], mode: "prefer", weight: Number($("#a-hybrid-weight", f).value) });
|
out.push({ field: "remote", values: ["hybrid"], mode: "prefer", weight: Number($("#a-hybrid-weight", f).value) });
|
||||||
@@ -627,6 +647,7 @@
|
|||||||
// under Where says them all, as the card will, rows included.
|
// under Where says them all, as the card will, rows included.
|
||||||
const gates = () => whereGates().concat(rules.map((r) => r.read()));
|
const gates = () => whereGates().concat(rules.map((r) => r.read()));
|
||||||
const view = () => {
|
const view = () => {
|
||||||
|
offer();
|
||||||
$("#a-gates", f).value = JSON.stringify(gates(), null, 2);
|
$("#a-gates", f).value = JSON.stringify(gates(), null, 2);
|
||||||
$("#a-where-sum", f).textContent = rulesLine(gates()) || "Keeps roles anywhere.";
|
$("#a-where-sum", f).textContent = rulesLine(gates()) || "Keeps roles anywhere.";
|
||||||
};
|
};
|
||||||
|
|||||||
+47
-29
@@ -24,21 +24,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** A `/api/suggest/places` answer as the value of a `remote_from` gate, or
|
/** A `/api/suggest/places` answer as the value of a `remote_from` gate, or
|
||||||
null when the Where block does not offer it: countries, regions and
|
null when the Where block does not offer it: countries and regions. A
|
||||||
Anywhere. A town, or a remote token that is not Anywhere (the block's
|
town or a remote token is left out; the block's own country pick is the
|
||||||
own country pick is the plain one), is left out. */
|
plain one. */
|
||||||
function fromSuggestion(s) {
|
function fromSuggestion(s) {
|
||||||
const token = String(s.token || "");
|
const token = String(s.token || "");
|
||||||
if (token === `remote:${ANYWHERE}`) return ANYWHERE;
|
return token.startsWith("country:") || token.startsWith("region:") ? token : null;
|
||||||
if (token.startsWith("country:") || token.startsWith("region:")) return token;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The words a person can type for Anywhere, which the suggestions may or
|
|
||||||
may not carry. */
|
|
||||||
function offersAnywhere(q) {
|
|
||||||
const text = String(q).trim().toLowerCase();
|
|
||||||
return text.length > 0 && ["anywhere", "worldwide"].some((w) => w.startsWith(text));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The chip label of a gate value when the server has not said it yet. */
|
/** The chip label of a gate value when the server has not said it yet. */
|
||||||
@@ -57,36 +48,63 @@
|
|||||||
return `remote from ${list}`;
|
return `remote from ${list}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Europe as the starter agents in config.example.yaml spell it: the EEA,
|
||||||
|
the UK and Switzerland, and EU for a role open anywhere in Europe. */
|
||||||
|
const EUROPE = ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR",
|
||||||
|
"HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE",
|
||||||
|
"IS", "LI", "NO", "GB", "CH", "EU"];
|
||||||
|
|
||||||
|
/** What "Only roles in: Europe" sends: Europe, and the countries line too,
|
||||||
|
since the require gate holds for every role, not only the remote ones. */
|
||||||
|
function europeWith(countries) {
|
||||||
|
return [...EUROPE, ...countries.filter((c) => !EUROPE.includes(c))];
|
||||||
|
}
|
||||||
|
|
||||||
/** Share out an agent's gates between the Where block and Other rules. Each
|
/** Share out an agent's gates between the Where block and Other rules. Each
|
||||||
Where line takes the first gate it can say whole; the rest are rows. A
|
Where line takes the first gate it can say whole; the rest are rows. A
|
||||||
must or one-of gate with a weight other than the default stays a row,
|
must or one-of gate with a weight other than the default stays a row,
|
||||||
since Where would drop it. The remote line is a `remote_from` one-of, or
|
since Where would drop it.
|
||||||
the older one-of on `remote: [remote]`, which reads as remote from
|
|
||||||
Anywhere; both save as `remote_from`. Every require gate on country is a
|
The scope line is the first plain require gate on country: `europe`
|
||||||
row, "within Europe" among them: it holds for every role and not only
|
when it is exactly Europe and the countries line (`europeWith`),
|
||||||
the remote ones, so the block does not fold it into the remote line. */
|
`countries` with its codes as chips otherwise, `everywhere` when there
|
||||||
|
is none. Any other require gate on country is a row. The remote line is
|
||||||
|
`scope` for the one-of on `remote: [remote]` (remote, within the
|
||||||
|
scope), `from` for a one-of on `remote_from`, else `none`; when both
|
||||||
|
are there `remote_from` wins and the plain one stays a row. */
|
||||||
function distribute(gates) {
|
function distribute(gates) {
|
||||||
const where = { countries: null, places: null, remote: null, hybrid: null };
|
const where = { scope: null, countries: null, places: null, remote: { mode: "none", values: [] }, hybrid: null };
|
||||||
const rest = [];
|
const rest = [];
|
||||||
const plain = (g) => g.weight === undefined || g.weight === 1;
|
const plain = (g) => g.weight === undefined || g.weight === 1;
|
||||||
const only = (g, value) => g.values.length === 1 && g.values[0] === value;
|
const only = (g, value) => g.values.length === 1 && g.values[0] === value;
|
||||||
|
let must = null;
|
||||||
let older = null;
|
let older = null;
|
||||||
|
let from = null;
|
||||||
for (const g of gates) {
|
for (const g of gates) {
|
||||||
if (g.field === "country" && g.mode === "any" && plain(g) && !where.countries) where.countries = g;
|
if (g.field === "country" && g.mode === "require" && plain(g) && !must) must = g;
|
||||||
|
else if (g.field === "country" && g.mode === "any" && plain(g) && !where.countries) where.countries = g;
|
||||||
else if (g.field === "place" && g.mode === "any" && plain(g) && !where.places) where.places = g;
|
else if (g.field === "place" && g.mode === "any" && plain(g) && !where.places) where.places = g;
|
||||||
else if (g.field === "remote_from" && g.mode === "any" && plain(g) && !where.remote) {
|
else if (g.field === "remote_from" && g.mode === "any" && plain(g) && !from) from = g;
|
||||||
where.remote = { values: g.values.map(String) };
|
else if (g.field === "remote" && g.mode === "any" && plain(g) && only(g, "remote") && !older) older = g;
|
||||||
} else if (g.field === "remote" && g.mode === "any" && plain(g) && only(g, "remote") && !older) {
|
else if (g.field === "remote" && g.mode === "prefer" && only(g, "hybrid") && !where.hybrid) where.hybrid = g;
|
||||||
older = g;
|
|
||||||
} else if (g.field === "remote" && g.mode === "prefer" && only(g, "hybrid") && !where.hybrid) where.hybrid = g;
|
|
||||||
else rest.push(g);
|
else rest.push(g);
|
||||||
}
|
}
|
||||||
if (older) {
|
if (from) {
|
||||||
if (where.remote) rest.push(older);
|
where.remote = { mode: "from", values: from.values.map(String) };
|
||||||
else where.remote = { values: [ANYWHERE] };
|
if (older) rest.push(older);
|
||||||
|
} else if (older) {
|
||||||
|
where.remote = { mode: "scope", values: [] };
|
||||||
|
}
|
||||||
|
if (!must) {
|
||||||
|
where.scope = { kind: "everywhere", values: [] };
|
||||||
|
} else {
|
||||||
|
const values = must.values.map(String);
|
||||||
|
const within = new Set(europeWith(where.countries ? where.countries.values.map(String) : []));
|
||||||
|
const europe = values.length === within.size && values.every((v) => within.has(v));
|
||||||
|
where.scope = europe ? { kind: "europe", values: [] } : { kind: "countries", values };
|
||||||
}
|
}
|
||||||
return { where, rest };
|
return { where, rest };
|
||||||
}
|
}
|
||||||
|
|
||||||
window.remoteHelpers = { ANYWHERE, remoteBadge, fromSuggestion, offersAnywhere, fallbackLabel, remoteSentence, distribute };
|
window.remoteHelpers = { ANYWHERE, EUROPE, europeWith, remoteBadge, fromSuggestion, fallbackLabel, remoteSentence, distribute };
|
||||||
})();
|
})();
|
||||||
+10
-4
@@ -128,7 +128,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// The place suggestion's kind, as its hint says it: a `place:` token is a
|
// The place suggestion's kind, as its hint says it: a `place:` token is a
|
||||||
// town, a `remote:` token the remote roles a person there can take, its
|
// town, a `remote:` token remote roles (`remote:any` within the viewing
|
||||||
|
// agent's scope, `remote:country:DK` those a person there can take), its
|
||||||
// count the roles it would find (`places.suggest`).
|
// count the roles it would find (`places.suggest`).
|
||||||
const PLACE_KINDS = { country: "country", region: "region", place: "town", remote: "remote" };
|
const PLACE_KINDS = { country: "country", region: "region", place: "town", remote: "remote" };
|
||||||
|
|
||||||
@@ -1659,11 +1660,16 @@
|
|||||||
placeholder: "Company", label: "Company",
|
placeholder: "Company", label: "Company",
|
||||||
});
|
});
|
||||||
placeChips = chipInput($("#f-place"), {
|
placeChips = chipInput($("#f-place"), {
|
||||||
suggest: (q) => api(`/api/suggest/places?${new URLSearchParams({ q })}`)
|
suggest: (q) => {
|
||||||
.then((rows) => rows.map((s) => ({
|
// The viewing agent, so "Remote" counts the remote roles within its
|
||||||
|
// scope; the server may ignore it.
|
||||||
|
const p = new URLSearchParams({ q });
|
||||||
|
if (state.filter.agent !== null) p.set("agent", String(state.filter.agent));
|
||||||
|
return api(`/api/suggest/places?${p}`).then((rows) => rows.map((s) => ({
|
||||||
value: s.token, label: s.label,
|
value: s.token, label: s.label,
|
||||||
hint: `${PLACE_KINDS[s.kind] || s.kind} · ${number.format(s.count)}`,
|
hint: `${PLACE_KINDS[s.kind] || s.kind} · ${number.format(s.count)}`,
|
||||||
}))),
|
})));
|
||||||
|
},
|
||||||
onChange: (items) => {
|
onChange: (items) => {
|
||||||
items.forEach((i) => placeLabels.set(i.value, i.label));
|
items.forEach((i) => placeLabels.set(i.value, i.label));
|
||||||
setFilter({ places: items.map((i) => i.value) });
|
setFilter({ places: items.map((i) => i.value) });
|
||||||
|
|||||||
@@ -29,6 +29,16 @@
|
|||||||
<fieldset class="where">
|
<fieldset class="where">
|
||||||
<legend>Where can the role be?</legend>
|
<legend>Where can the role be?</legend>
|
||||||
<span class="hint">Each line adds places. A role is kept when it fits at least one line, so a line more means more roles, never fewer. With every line empty a role can be anywhere. A role whose location is not known yet ranks until extract reads the posting.</span>
|
<span class="hint">Each line adds places. A role is kept when it fits at least one line, so a line more means more roles, never fewer. With every line empty a role can be anywhere. A role whose location is not known yet ranks until extract reads the posting.</span>
|
||||||
|
<div class="where-line">
|
||||||
|
<span>Only roles in:</span>
|
||||||
|
<select id="a-scope" aria-label="Only roles in">
|
||||||
|
<option value="europe">Europe</option>
|
||||||
|
<option value="countries">Chosen countries</option>
|
||||||
|
<option value="everywhere">Everywhere</option>
|
||||||
|
</select>
|
||||||
|
<div id="a-scope-countries"></div>
|
||||||
|
</div>
|
||||||
|
<span class="hint">Every role must be in this, whatever the lines below add. A company set to All countries is read within this.</span>
|
||||||
<div class="where-line">
|
<div class="where-line">
|
||||||
<span>Anywhere in</span>
|
<span>Anywhere in</span>
|
||||||
<div id="a-countries"></div>
|
<div id="a-countries"></div>
|
||||||
@@ -39,10 +49,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<span class="hint">Towns are for places outside the countries above: with Denmark above, Malmö here adds Malmö to all of Denmark. A town inside a country above changes nothing, since the whole country is in already.</span>
|
<span class="hint">Towns are for places outside the countries above: with Denmark above, Malmö here adds Malmö to all of Denmark. A town inside a country above changes nothing, since the whole country is in already.</span>
|
||||||
<div class="where-line">
|
<div class="where-line">
|
||||||
<span>Remote, open to someone in:</span>
|
<span>Remote:</span>
|
||||||
|
<select id="a-remote" aria-label="Remote">
|
||||||
|
<option value="none">no</option>
|
||||||
|
<option value="scope">anywhere within the scope</option>
|
||||||
|
<option value="from">only when open to someone in:</option>
|
||||||
|
</select>
|
||||||
<div id="a-remote-from"></div>
|
<div id="a-remote-from"></div>
|
||||||
</div>
|
</div>
|
||||||
<span class="hint">A remote role is kept when it can be worked from one of these; Anywhere is for roles open worldwide. A remote role whose area is not stated yet ranks until extract reads the posting.</span>
|
<span class="hint">Remote roles are kept on top of the lines above. A remote role whose area is not stated yet ranks until extract reads the posting.</span>
|
||||||
<label class="inline where-rank"><input type="checkbox" id="a-hybrid"> Prefer hybrid<span id="a-hybrid-weight-line">, adding <input type="number" id="a-hybrid-weight" min="0" step="0.05" value="0.05" aria-label="Weight of hybrid"></span></label>
|
<label class="inline where-rank"><input type="checkbox" id="a-hybrid"> Prefer hybrid<span id="a-hybrid-weight-line">, adding <input type="number" id="a-hybrid-weight" min="0" step="0.05" value="0.05" aria-label="Weight of hybrid"></span></label>
|
||||||
<span class="hint">This one ranks rather than filters: a hybrid role gains a little.</span>
|
<span class="hint">This one ranks rather than filters: a hybrid role gains a little.</span>
|
||||||
<p id="a-where-sum" class="where-sum" role="status"></p>
|
<p id="a-where-sum" class="where-sum" role="status"></p>
|
||||||
|
|||||||
+56
-32
@@ -31,22 +31,15 @@ test("the badge leaves the other words as they are, and a role with none blank",
|
|||||||
assert.equal(rh.remoteBadge(null), "");
|
assert.equal(rh.remoteBadge(null), "");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a suggestion is offered to the remote line as a country, a region or Anywhere", () => {
|
test("a suggestion is offered to the remote line as a country or a region only", () => {
|
||||||
assert.equal(rh.fromSuggestion({ token: "country:DK", kind: "country" }), "country:DK");
|
assert.equal(rh.fromSuggestion({ token: "country:DK", kind: "country" }), "country:DK");
|
||||||
assert.equal(rh.fromSuggestion({ token: "country:EU", kind: "country" }), "country:EU");
|
assert.equal(rh.fromSuggestion({ token: "country:EU", kind: "country" }), "country:EU");
|
||||||
assert.equal(rh.fromSuggestion({ token: "region:oresund", kind: "region" }), "region:oresund");
|
assert.equal(rh.fromSuggestion({ token: "region:oresund", kind: "region" }), "region:oresund");
|
||||||
assert.equal(rh.fromSuggestion({ token: "remote:anywhere", kind: "remote" }), "anywhere");
|
assert.equal(rh.fromSuggestion({ token: "remote:any", kind: "remote" }), null);
|
||||||
assert.equal(rh.fromSuggestion({ token: "remote:country:DK", kind: "remote" }), null);
|
assert.equal(rh.fromSuggestion({ token: "remote:country:DK", kind: "remote" }), null);
|
||||||
assert.equal(rh.fromSuggestion({ token: "place:1", kind: "place" }), null);
|
assert.equal(rh.fromSuggestion({ token: "place:1", kind: "place" }), null);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Anywhere is offered for the words that start it", () => {
|
|
||||||
assert.equal(rh.offersAnywhere("any"), true);
|
|
||||||
assert.equal(rh.offersAnywhere(" World"), true);
|
|
||||||
assert.equal(rh.offersAnywhere("den"), false);
|
|
||||||
assert.equal(rh.offersAnywhere(""), false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("a value has a label before the server has said it", () => {
|
test("a value has a label before the server has said it", () => {
|
||||||
assert.equal(label("anywhere"), "Anywhere");
|
assert.equal(label("anywhere"), "Anywhere");
|
||||||
assert.equal(label("country:DK"), "Denmark");
|
assert.equal(label("country:DK"), "Denmark");
|
||||||
@@ -65,46 +58,77 @@ test("the sentence lists the areas, and says anywhere in lower case", () => {
|
|||||||
const older = { field: "remote", values: ["remote"], mode: "any" };
|
const older = { field: "remote", values: ["remote"], mode: "any" };
|
||||||
const from = (...values) => ({ field: "remote_from", values, mode: "any" });
|
const from = (...values) => ({ field: "remote_from", values, mode: "any" });
|
||||||
const hybrid = { field: "remote", values: ["hybrid"], mode: "prefer", weight: 0.05 };
|
const hybrid = { field: "remote", values: ["hybrid"], mode: "prefer", weight: 0.05 };
|
||||||
const europe = { field: "country", values: ["DK", "SE", "EU"], mode: "require" };
|
const dk = { field: "country", values: ["DK"], mode: "any" };
|
||||||
|
const must = (...values) => ({ field: "country", values, mode: "require" });
|
||||||
|
const europe = must(...rh.EUROPE);
|
||||||
|
|
||||||
test("no remote gate: the remote line is empty", () => {
|
test("no gates: everywhere, no remote", () => {
|
||||||
const { where, rest } = rh.distribute([{ field: "country", values: ["DK"], mode: "any" }, hybrid]);
|
const { where, rest } = rh.distribute([]);
|
||||||
assert.equal(where.remote, null);
|
assert.deepEqual(where.scope, { kind: "everywhere", values: [] });
|
||||||
assert.equal(where.hybrid, hybrid);
|
assert.deepEqual(where.remote, { mode: "none", values: [] });
|
||||||
assert.deepEqual(rest, []);
|
assert.deepEqual(rest, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a remote_from gate loads into the remote line", () => {
|
test("the Europe list is the Europe scope", () => {
|
||||||
const { where, rest } = rh.distribute([from("country:DK", "anywhere")]);
|
const { where, rest } = rh.distribute([europe, dk, older]);
|
||||||
assert.deepEqual(where.remote, { values: ["country:DK", "anywhere"] });
|
assert.equal(where.scope.kind, "europe");
|
||||||
|
assert.equal(where.countries.values[0], "DK");
|
||||||
assert.deepEqual(rest, []);
|
assert.deepEqual(rest, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("the older remote gate loads as remote from Anywhere", () => {
|
test("Europe with the countries line added is still the Europe scope", () => {
|
||||||
const { where, rest } = rh.distribute([older]);
|
const us = { field: "country", values: ["US"], mode: "any" };
|
||||||
assert.deepEqual(where.remote, { values: ["anywhere"] });
|
const { where } = rh.distribute([must(...rh.europeWith(["US"])), us]);
|
||||||
|
assert.equal(where.scope.kind, "europe");
|
||||||
|
// The same gate without the line's country is not exactly Europe: chips.
|
||||||
|
assert.equal(rh.distribute([europe, us]).where.scope.kind, "countries");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("any other require gate on country is the scope with its codes as chips", () => {
|
||||||
|
const { where, rest } = rh.distribute([must("DK", "SE"), dk]);
|
||||||
|
assert.deepEqual(where.scope, { kind: "countries", values: ["DK", "SE"] });
|
||||||
assert.deepEqual(rest, []);
|
assert.deepEqual(rest, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a remote_from gate wins over the older one, which stays a row", () => {
|
test("a second or weighted require gate on country stays a row", () => {
|
||||||
|
const second = must("NO");
|
||||||
|
const weighted = { ...must("DE"), weight: 2 };
|
||||||
|
const { where, rest } = rh.distribute([europe, second, weighted]);
|
||||||
|
assert.equal(where.scope.kind, "europe");
|
||||||
|
assert.deepEqual(rest, [second, weighted]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a require gate on another field is a row and leaves the scope everywhere", () => {
|
||||||
|
const level = { field: "seniority", values: ["senior"], mode: "require" };
|
||||||
|
const { where, rest } = rh.distribute([level]);
|
||||||
|
assert.equal(where.scope.kind, "everywhere");
|
||||||
|
assert.deepEqual(rest, [level]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("remote, three modes: the plain gate is within the scope", () => {
|
||||||
|
const scope = rh.distribute([older, hybrid]);
|
||||||
|
assert.deepEqual(scope.where.remote, { mode: "scope", values: [] });
|
||||||
|
assert.equal(scope.where.hybrid, hybrid);
|
||||||
|
assert.deepEqual(scope.rest, []);
|
||||||
|
assert.deepEqual(rh.distribute([hybrid]).where.remote, { mode: "none", values: [] });
|
||||||
|
const named = rh.distribute([from("country:DK", "region:oresund")]);
|
||||||
|
assert.deepEqual(named.where.remote, { mode: "from", values: ["country:DK", "region:oresund"] });
|
||||||
|
assert.deepEqual(named.rest, []);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a remote_from gate wins over the plain one, which stays a row", () => {
|
||||||
for (const gates of [[older, from("country:DK")], [from("country:DK"), older]]) {
|
for (const gates of [[older, from("country:DK")], [from("country:DK"), older]]) {
|
||||||
const { where, rest } = rh.distribute(gates);
|
const { where, rest } = rh.distribute(gates);
|
||||||
assert.deepEqual(where.remote, { values: ["country:DK"] });
|
assert.deepEqual(where.remote, { mode: "from", values: ["country:DK"] });
|
||||||
assert.deepEqual(rest, [older]);
|
assert.deepEqual(rest, [older]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("the within Europe must is a row, kept whole", () => {
|
|
||||||
const { where, rest } = rh.distribute([europe, older]);
|
|
||||||
assert.deepEqual(where.remote, { values: ["anywhere"] });
|
|
||||||
assert.deepEqual(rest, [europe]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("a second remote_from gate, a weighted one or a must stays a row", () => {
|
test("a second remote_from gate, a weighted one or a must stays a row", () => {
|
||||||
const second = from("country:SE");
|
const second = from("country:SE");
|
||||||
const weighted = { ...from("country:DE"), weight: 2 };
|
const weighted = { ...from("country:DE"), weight: 2 };
|
||||||
const must = { field: "remote_from", values: ["country:DK"], mode: "require" };
|
const required = { field: "remote_from", values: ["country:DK"], mode: "require" };
|
||||||
const { where, rest } = rh.distribute([from("country:DK"), second, weighted, must]);
|
const { where, rest } = rh.distribute([from("country:DK"), second, weighted, required]);
|
||||||
assert.deepEqual(where.remote, { values: ["country:DK"] });
|
assert.deepEqual(where.remote, { mode: "from", values: ["country:DK"] });
|
||||||
assert.deepEqual(rest, [second, weighted, must]);
|
assert.deepEqual(rest, [second, weighted, required]);
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user