Drop the hybrid prefer gate and the gate weight from remote.js distribute
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
680744278a
commit
fbc0f16c4a
2 files changed
+37
-26
No files matched your search
+13
-14
@@ -1,6 +1,6 @@
|
||||
/* Where a remote role may be worked from, as the pages say it: the words of
|
||||
* the badge, the picks of the agent's "Remote, open to someone in" chips, and
|
||||
* how an agent's gates share out between the Where block and Other rules. No
|
||||
* how an agent's gates share out between the fetch gate's blocks and Other rules. No
|
||||
* DOM in it, so `tests/js/remote.test.mjs` can walk it without a browser.
|
||||
*
|
||||
* The area is a place token in three spellings, one per layer: `remote:<place
|
||||
@@ -60,10 +60,11 @@
|
||||
return [...EUROPE, ...countries.filter((c) => !EUROPE.includes(c))];
|
||||
}
|
||||
|
||||
/** 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
|
||||
must or one-of gate with a weight other than the default stays a row,
|
||||
since Where would drop it.
|
||||
/** Share out an agent's gates between the fetch gate's blocks (region,
|
||||
place, titles to leave out) and Other rules. Each line takes the first
|
||||
gate it can say whole; the rest are rows. A gate has a field, values and
|
||||
a mode (require, any, exclude) and no weight; a gate with a mode the
|
||||
form does not know, such as an old prefer, stays a row.
|
||||
|
||||
The scope line is the first plain require gate on country: `europe`
|
||||
when it is exactly Europe and the countries line (`europeWith`),
|
||||
@@ -73,21 +74,19 @@
|
||||
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) {
|
||||
const where = { scope: null, countries: null, places: null, remote: { mode: "none", values: [] }, hybrid: null, titles: null };
|
||||
const where = { scope: null, countries: null, places: null, remote: { mode: "none", values: [] }, titles: null };
|
||||
const rest = [];
|
||||
const plain = (g) => g.weight === undefined || g.weight === 1;
|
||||
const only = (g, value) => g.values.length === 1 && g.values[0] === value;
|
||||
let must = null;
|
||||
let older = null;
|
||||
let from = null;
|
||||
for (const g of gates) {
|
||||
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 === "remote_from" && g.mode === "any" && plain(g) && !from) from = g;
|
||||
else if (g.field === "remote" && g.mode === "any" && plain(g) && only(g, "remote") && !older) older = g;
|
||||
else if (g.field === "remote" && g.mode === "prefer" && only(g, "hybrid") && !where.hybrid) where.hybrid = g;
|
||||
else if (g.field === "title" && g.mode === "exclude" && plain(g) && !where.titles) where.titles = g;
|
||||
if (g.field === "country" && g.mode === "require" && !must) must = g;
|
||||
else if (g.field === "country" && g.mode === "any" && !where.countries) where.countries = g;
|
||||
else if (g.field === "place" && g.mode === "any" && !where.places) where.places = g;
|
||||
else if (g.field === "remote_from" && g.mode === "any" && !from) from = g;
|
||||
else if (g.field === "remote" && g.mode === "any" && only(g, "remote") && !older) older = g;
|
||||
else if (g.field === "title" && g.mode === "exclude" && !where.titles) where.titles = g;
|
||||
else rest.push(g);
|
||||
}
|
||||
if (from) {
|
||||
|
||||
Reference in new issue
Block a user