From 79cb1f8f8a7f7c26ed71855f3f9ccb6e1d449d37 Mon Sep 17 00:00:00 2001 From: Marvin Ma Date: Mon, 16 Nov 2026 08:32:03 +0900 Subject: [PATCH] Review shows one pair of each pattern below the review floor, on a switch: list scored --each keeps one pair of each pattern the filters keep, the patterns of most pairs first, each with the pairs it stands for Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012o8JNBKSY1aREPbMQDG8g2 --- docs/commands.md | 9 +++++---- docs/usage.md | 2 +- er/cli.py | 12 +++++++----- er/results.py | 19 ++++++++++++++----- er/ui.html | 20 +++++++++++++------- tests/test_ui_page.py | 6 ++++++ tests/test_workspace.py | 7 +++++++ 7 files changed, 53 insertions(+), 22 deletions(-) diff --git a/docs/commands.md b/docs/commands.md index 94e5ba7..6d6f2d5 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -1526,10 +1526,10 @@ nayose describe results --workspace workspaces/customers The pairs the run scored, best first, a page at a time. ``` -nayose list scored --workspace WORKSPACE [--from POINTS] [--to POINTS] [--source rules|model] [--status waiting|merged|same|different|open] [--record ID] [--page N] [--count N] [--pipeline PIPELINE] [--format text|json] +nayose list scored --workspace WORKSPACE [--from POINTS] [--to POINTS] [--source rules|model] [--status waiting|merged|same|different|open] [--record ID] [--page N] [--count N] [--each] [--pipeline PIPELINE] [--format text|json] ``` -Every pair the run scored at 0 points or more and every rule pair, best first: both IDs, points, how each was found (keys, rule), its status (waiting, merged, same, different: people's), each comparison's level and points, and both records' compared fields; filtered by points, by how found, by status or by a record ID; with the total the filters keep. O(E log E) + O(page·F). +Every pair the run scored at 0 points or more and every rule pair, best first: both IDs, points, how each was found (keys, rule), its status (waiting, merged, same, different: people's), each comparison's level and points, and both records' compared fields; filtered by points, by how found, by status or by a record ID; with the total the filters keep. With --each, one pair of each pattern the filters keep, the patterns of most pairs first: below the review floor, the kinds of pair nobody is asked about, one of each to see. O(E log E) + O(page·F). | Parameter | | |---|---| @@ -1541,15 +1541,16 @@ Every pair the run scored at 0 points or more and every rule pair, best first: b | `--record ID` | pairs of this record ID | | `--page N` | the page (default 1) | | `--count N` | pairs a page (default 100) | +| `--each` | one pair of each pattern (each comparison's level), the patterns of most pairs first | | `--pipeline PIPELINE` | the pipeline file (default: config/final.toml) | | Result | | |---|---| -| `total` | pairs the filters keep | +| `total` | pairs the filters keep (with --each: patterns) | | `typed` | of them, decided and not applied yet | | `page` | this page | | `count` | pairs a page | -| `pairs` | each pair: first, second, points, sources, rule, status, said, applied, compared (comparison: level, points), fields (field: [first, second]), household (maybe two people of one household) | +| `pairs` | each pair: first, second, points, sources, rule, status, said, applied, compared (comparison: level, points), like (with --each: the pairs of its pattern), fields (field: [first, second]), household (maybe two people of one household) | ```bash nayose list scored --workspace workspaces/customers --status waiting --from 6 diff --git a/docs/usage.md b/docs/usage.md index b1c3616..cc02d5a 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -537,7 +537,7 @@ open ui` prints a new link: the old one says to open it. | 1 Choose a workspace | *What will this do for me?* An example: three records written differently become one entity, one ID, and *Create a workspace*, or *Auto mode*: every step on one file, each listed as it ends. *Can I pick up where I left off?* The latest workspaces, each with where it stands, and *Open* | `list workspaces`, `create workspace`, `try everything` | | 2 Prepare your data | Two cards side by side, built alike: a question, its answer, a search, one list, then *Load another file*. *Customer information*: a records file dropped anywhere on the card or chosen (*Drop or choose a file*), sent into the workspace and loaded from there, or its path on this computer, with *Load*; or synthetic records by size and difficulty, folded, with *Generate* ([Synthetic records](#synthetic-records)); once loaded, the file, its records and columns, what waits for a repair or what is still needed (with *Suggest the columns*), and what may hurt the matching: fields mostly empty, and fields no column is mapped to with the ways of finding pairs they turn off. Then the repairs: each kind the reader proposed, its values as given and repaired, with *Accept these N*; what it fixed by itself; the rows it can't read. Then one list of the columns, group by group, a group folded unless something in it needs a look: each feature with how full it is and what its values say is off, with the button that sets it right, and under it its columns as rows in the order they are read (the first; where it is empty, the next), each with how full it is and an example. A row is dragged by ⠿ above or below another, onto one to be joined to it, or down among *Other columns* (the file's columns no feature reads) to be taken off, a folded group opening as it is held over; Alt+↑ ↓ moves it by keys. A column clicked lists the file's columns to put another in its place, and + adds one read where the others are empty; *Suggest* shows what the file's contents place there, kept with *Keep*; one search over every group. *Policy information*, in view as the left side scrolls: the details file ([Details beside each record](#details-beside-each-record)), dropped, chosen or its path, with *Load*, and its ID column, folded; once loaded, its rows and the share of records that have some, then one list of its columns, each with how full it is and an example: those shown in reviews first, in their order, each dragged by ⠿ (or moved with Alt+↑ ↓), the first naming each policy; then the others, ticked to add. A file dragged over the page shows the card that takes it; a file's upload says how far it is in the panel, as a long command does. As a file is read, its columns show at once among the features, then each one's share filled in its first 200,000 rows, read only until the whole of it is read and its suggestions and hints come. The line between the two cards is dragged to make one wider, and the next visit keeps it. A change shows at once and is saved behind it, one after another | `load records`, `generate records`, `describe records`, `accept repairs`, `set feature`, `set names`, `set preparation`, `add feature`, `remove feature`, `load details`, `set details`, `describe workspace` | | 3 Find matches | Before a run, *how long will it take?* The records and about how long, and *Find matches*. During it, *is it working?* What it is doing now, the seconds so far and about how long is left, and each stage filling in as its step ends. Before a run, the estimate scales this workspace's last full run to the records, else this machine's reading of the file. During it, the time left is only what this machine measured on this file: a step that counts its work (records loaded, rules applied, keys joined, pairs scored) by its own pace so far, any other by its time in this workspace's last full run, scaled to the records, and the steps after it by that run. What nothing measured yet covers (a first run's later steps) makes it *at least* the time it can count, and with nothing to count it shows only the time so far. The bar is the work done, not the time spent: a step running past its last time holds it and says it is taking longer than last time, rather than stretching the estimate. Left and opened again while it runs, step 3 shows the run as it stands. After it, the records and the entities they became, and *Results*; then *what limits what the run finds?* ([section 7](#7--when-something-is-wrong)). Then *how did it find matches?* The stages in order, each opening its own question answered: *What did it read?* · *Which pairs did the rules match, and why?* (how the scoring rates the rules' pairs, and where it disagrees) · *Which pairs did it compare, and could a real match have been missed?* (all the possible pairs, how long comparing them all would take, the pairs compared; then a sample of the pairs that share a phone or a postal area, scored: the matches the method missed, with their estimate and the pairs found; each key opens `describe key`) · *How did it score each pair?* (one pair of the run as a waterfall, *Another pair*, and what counts most; every comparison's staircase folded) · *Where did it draw the line, and how many could be wrong?* (the line and its odds, the pairs matched and the wrong ones the model expects, pairs by points; every pattern folded) · *How did matched pairs become entities?* (with what to look at first) | `resolve records`, `add records`, `match records`, `rerun records`, `describe workspace`, `list patterns`, `explain pair`, `compare records`, `describe key` | -| *Review* | Tab *Same customer?*: the pairs waiting for you, best first, from *Review from* points (this browser keeps it), 100 a page, or a record ID's. The pair first and wide: its points and what found it; *Same*, *Different*, *Not sure* (M, N, S; ↑ ↓ move) and what each does; then both full rows, with every other candidate of either record beside them ([Full rows](#full-rows)), and how it scored, folded, with *Why?* beside each step ([Why this match?](#why-this-match)). Beside it, how many wait and how many are decided, *Apply decisions*, then the list, a decided pair marked; the line between the two dragged (or moved with ← →) widens either, on every page with one, and this browser keeps it. *Auto-merge* opens the conditions under which pairs merge without you ([section 6](#merge-by-your-own-conditions)): points, rules, fields that agree, all or any of them, what they would merge counted as they change, then *Apply*; *Turn off* parts what they joined. Tab *Person or company?*: two parts, *Flagged* (the engine sure against the file's flag, surest first) and *Teach the engine* (optional: the draw at random). *Is this record a person or a company?* The name, large; what the engine thinks, and why the record is asked; the answers (1 person, 2 company, 0 can't tell), saved as given; *Apply answers* matches again with them ([Persons and companies](#persons-and-companies)) | `list scored`, `show records`, `show details`, `explain pair`, `decide pair`, `apply decisions`, `describe results`, `describe merging`, `set merging`, `list kinds`, `answer kind`, `apply answers` | +| *Review* | Tab *Same customer?*: the pairs waiting for you, best first, from *Review from* points (this browser keeps it), 100 a page, or a record ID's. *One of each pattern below* (this browser keeps it too) shows instead one open pair of each pattern below those points, the patterns of most pairs first, each with how many pairs it stands for: the kinds of pair nobody is asked about, one of each to see and decide. The pair first and wide: its points and what found it; *Same*, *Different*, *Not sure* (M, N, S; ↑ ↓ move) and what each does; then both full rows, with every other candidate of either record beside them ([Full rows](#full-rows)), and how it scored, folded, with *Why?* beside each step ([Why this match?](#why-this-match)). Beside it, how many wait and how many are decided, *Apply decisions*, then the list, a decided pair marked; the line between the two dragged (or moved with ← →) widens either, on every page with one, and this browser keeps it. *Auto-merge* opens the conditions under which pairs merge without you ([section 6](#merge-by-your-own-conditions)): points, rules, fields that agree, all or any of them, what they would merge counted as they change, then *Apply*; *Turn off* parts what they joined. Tab *Person or company?*: two parts, *Flagged* (the engine sure against the file's flag, surest first) and *Teach the engine* (optional: the draw at random). *Is this record a person or a company?* The name, large; what the engine thinks, and why the record is asked; the answers (1 person, 2 company, 0 can't tell), saved as given; *Apply answers* matches again with them ([Persons and companies](#persons-and-companies)) | `list scored`, `show records`, `show details`, `explain pair`, `decide pair`, `apply decisions`, `describe results`, `describe merging`, `set merging`, `list kinds`, `answer kind`, `apply answers` | | *Explore* | Tab *Pairs*: *Which pairs scored highest?* The score chart (what it leaves out said, with *Run matching again*), then every pair at 0 points or more, as many as it says, best first, 100 a page, filtered by points, how it was found, its status or a record ID; a pair opens its full rows and how it scored. Tab *Entities*: *Which records became one customer?* Entities by size, then those of two records or more, largest first, or a record ID's; one opens the links that joined its records (a rule, the model, you, or your conditions) and their full rows. Tab *Records*: *Which record?* A record ID's full row as the file gave it, its entity, and the pairs it is in. Tab *How it works*: the stages, as on *Find matches* | `list scored`, `list entities`, `show records`, `show details`, `describe entity`, `explain pair`, `describe results`, `describe matching`, `describe key`, `list patterns`, `compare records` | | *Method*, under Setup | *Is the matching good enough yet?* From the pairs people checked: not known yet, so far yes (with *Review pairs*), or how many were wrong, with *Look at them*: the pairs people said differ, in *Explore*. *What could be better?* Each change worth trying in words, with what it would do, and *Try*; a trial tried, with *Adopt*; where to draw the line, folded. *How many records should the model learn from?* The fit as set, and *Try sample sizes*. *Which fields should EM learn from?* As tuned, chosen by each run, or the fields named, and *✦ Choose EM fields*: each session's pairs, its share agreeing on the given name, kept or dropped and why, then *Find matches*. The rounds, rules, pair keys and comparison steps folded ([section 6](#improve-the-method)) | `describe method`, `try method`, `adopt method`, `reset method`, `try sample`, `set fit`, `choose em`, `describe key` | diff --git a/er/cli.py b/er/cli.py index 4a882bf..50f69e9 100644 --- a/er/cli.py +++ b/er/cli.py @@ -1032,7 +1032,7 @@ def list_scored_(a: dict, emit: "Emit") -> dict: con, db = connect(s.compute) num = lambda k: number(a[k], f"--{k}") if a.get(k) not in (None, "") else None r = list_scored(con, db, Path(a["workspace"]), s, p, num("from"), num("to"), a.get("source"), a.get("status"), a.get("record") or None, - counted(a, "page", 1), counted(a, "count", 100)) + counted(a, "page", 1), counted(a, "count", 100), bool(a.get("each"))) for x in r["pairs"]: x["found"] = found_words(p, x) return r @@ -1735,14 +1735,16 @@ def open_ui(a: dict, emit: "Emit") -> dict: "Every pair the run scored at 0 points or more and every rule pair, best first: both IDs, points, how each was " "found (keys, rule), its status (waiting, merged, same, different: people's), each comparison's level and " "points, and both records' compared fields; filtered by points, by how found, by status or by a record ID; " - "with the total the filters keep. O(E log E) + O(page·F).", + "with the total the filters keep. With --each, one pair of each pattern the filters keep, the patterns of most " + "pairs first: below the review floor, the kinds of pair nobody is asked about, one of each to see. O(E log E) + O(page·F).", (WORKSPACE, Param("from", "from these points", metavar="POINTS"), Param("to", "below these points", metavar="POINTS"), Param("source", "found by a rule, or by the model's keys", "choice", ("rules", "model")), Param("status", "one status only; open: waiting, or decided and not applied yet", "choice", ("waiting", "merged", "same", "different", "open")), Param("record", "pairs of this record ID", metavar="ID"), Param("page", "the page (default 1)", metavar="N"), - Param("count", "pairs a page (default 100)", metavar="N"), PIPELINE), - {"total": "pairs the filters keep", "typed": "of them, decided and not applied yet", "page": "this page", "count": "pairs a page", - "pairs": "each pair: first, second, points, sources, rule, status, said, applied, compared (comparison: level, points), fields (field: [first, second]), " + Param("count", "pairs a page (default 100)", metavar="N"), + Param("each", "one pair of each pattern (each comparison's level), the patterns of most pairs first", "flag"), PIPELINE), + {"total": "pairs the filters keep (with --each: patterns)", "typed": "of them, decided and not applied yet", "page": "this page", "count": "pairs a page", + "pairs": "each pair: first, second, points, sources, rule, status, said, applied, compared (comparison: level, points), like (with --each: the pairs of its pattern), fields (field: [first, second]), " "household (maybe two people of one household)"}, "nayose list scored --workspace workspaces/customers --status waiting --from 6", list_scored_, quick=True, show={"pairs": ("first", "second", "points", "status", "rule")}), diff --git a/er/results.py b/er/results.py index ed3a272..b219cf7 100644 --- a/er/results.py +++ b/er/results.py @@ -82,10 +82,13 @@ def _status_sql(con: duckdb.DuckDBPyConnection, out: Path, uid: str, index: str) def list_scored(con: duckdb.DuckDBPyConnection, db: object, out: Path, s: Settings, p: Pipeline, frm: float | None = None, to: float | None = None, - source: str | None = None, status: str | None = None, record: str | None = None, page: int = 1, count: int = 100) -> dict: + source: str | None = None, status: str | None = None, record: str | None = None, page: int = 1, count: int = 100, + each: bool = False) -> dict: """One page of the run's pairs at 0 points or more, best first: both IDs, points, how each was found, its status, each comparison's level and points, and both records' compared fields. `total` counts every pair the filters keep, - so the pages are honest. O(E log E) to order E pairs + O(page·F) for the fields.""" + so the pages are honest. With `each`, one pair of each pattern (each comparison's level) the filters keep, drawn by + a hash of its IDs, the patterns of most pairs first, each with `like`: the pairs it stands for. O(E log E) to order + E pairs + O(page·F) for the fields.""" uid = s.data.unique_id l, r = q(f"{uid}_l"), q(f"{uid}_r") rows = _status_sql(con, out, uid, pair_index(con, db, out, s, p)) @@ -94,10 +97,15 @@ def list_scored(con: duckdb.DuckDBPyConnection, db: object, out: Path, s: Settin # open: waiting, or decided and not applied yet, so a queue holds still while people decide it where += ["(status = 'waiting' OR NOT coalesce(applied, TRUE))" if status == "open" else f"status = {lit(status)}"] if status else [] where += [f"({l} = {lit(record)} OR {r} = {lit(record)})"] if record else [] - sql = f"SELECT * FROM ({rows}) WHERE {' AND '.join(where)}" + sql, order = f"SELECT * FROM ({rows}) WHERE {' AND '.join(where)}", f"match_weight DESC, {l}, {r}" + if each: + pattern = ", ".join(q(c) for c, *_ in con.execute(f"DESCRIBE {sql}").fetchall() if c.startswith("gamma_")) or "TRUE" + sql = (f"SELECT * FROM (SELECT *, count(*) OVER (PARTITION BY {pattern}) AS er_like FROM ({sql})) " + f"QUALIFY row_number() OVER (PARTITION BY {pattern} ORDER BY hash({l}, {r}), {l}, {r}) = 1") + order = f"er_like DESC, {order}" total, typed = con.execute(f"SELECT count(*), count(*) FILTER (said IS NOT NULL AND NOT applied) FROM ({sql})").fetchall()[0] page = max(1, int(page)) - frame = con.execute(f"SELECT * FROM ({sql}) ORDER BY match_weight DESC, {l}, {r} LIMIT {int(count)} OFFSET {(page - 1) * int(count)}").df() + frame = con.execute(f"SELECT * FROM ({sql}) ORDER BY {order} LIMIT {int(count)} OFFSET {(page - 1) * int(count)}").df() model, uidl, uidr = run_model(out), f"{uid}_l", f"{uid}_r" lv = levels(model) pairs = [] @@ -105,7 +113,8 @@ def list_scored(con: duckdb.DuckDBPyConnection, db: object, out: Path, s: Settin gammas = {c: int(x[f"gamma_{c}"]) for c in lv if f"gamma_{c}" in x and not pd.isna(x[f"gamma_{c}"])} compared = {c: dict(level=lv[c][g][0], points=round(lv[c][g][1], 2)) for c, g in gammas.items() if g in lv[c]} pairs.append(dict(first=x[uidl], second=x[uidr], points=round(float(x["match_weight"]), 2), sources=x["sources"], rule=x["rule"], - status=x["status"], said=x["said"], applied=x["applied"] if not pd.isna(x["applied"]) else None, compared=compared)) + status=x["status"], said=x["said"], applied=x["applied"] if not pd.isna(x["applied"]) else None, compared=compared, + **({"like": int(x["er_like"])} if each else {}))) return dict(total=int(total), typed=int(typed), page=page, count=int(count), pairs=_with_fields(con, out, s, p, pairs)) diff --git a/er/ui.html b/er/ui.html index 9efc78e..13abef8 100644 --- a/er/ui.html +++ b/er/ui.html @@ -661,7 +661,7 @@ {"command": "describe matching", "args": {"workspace": "@workspace"}, "reads": ["nodes"]}]}, {"id": "pairs", "title": "Review", "icon": "pairs", "what": "The pairs waiting for you, best first: both full rows side by side, then same or different.", "strip": ["score", "accept", "group"], - "uses": [{"command": "list scored", "args": {"workspace": "@workspace", "status": "@status", "from": "@from", "to": "@to", "source": "@source", "record": "@record", "page": "@page", "count": "@count"}, "reads": ["total", "typed", "page", "count", "pairs"]}, + "uses": [{"command": "list scored", "args": {"workspace": "@workspace", "status": "@status", "from": "@from", "to": "@to", "source": "@source", "record": "@record", "page": "@page", "count": "@count", "each": "@each"}, "reads": ["total", "typed", "page", "count", "pairs"]}, {"command": "show records", "args": {"ids": "@ids", "workspace": "@workspace"}, "reads": ["columns", "records"]}, {"command": "show details", "args": {"ids": "@ids", "workspace": "@workspace"}, "reads": ["file", "columns", "records"]}, {"command": "describe results", "args": {"workspace": "@workspace"}, "reads": ["records", "entities", "joined", "sizes", "scores", "candidates", "review_from", "waiting", "pairs", "merged_by", "merging", "missed", "too_big", "kinds"]}, @@ -2192,6 +2192,7 @@

Search

    ${item("lookup", "search", "Look up")}${icon("wand")}Auto-merge`, reviewTabs("pairs")) + `
    ${arg.note || ""}
    ${GRIP}
    +
    `; @@ -2213,16 +2214,20 @@

    Search

      ${item("lookup", "search", "Look up")} { $("written").textContent = String(written); $("apply").disabled = !written; - $("done-line").innerHTML = `${plural(left, "pair")} waiting from ${fmt(from)} points${written ? ` · ${fmt(written)} decided, to apply` : ""}`; - if (steps.steps && steps.steps.pairs) { steps.steps.pairs = {state: left || written ? "attention" : "done", line: left ? `${fmt(left)} waiting` : written ? `${fmt(written)} decided, to apply` : "all decided"}; rail(); } }; + $("done-line").innerHTML = (each ? `${plural(left, "pattern")} below ${fmt(from)} points, one pair each` : `${plural(left, "pair")} waiting from ${fmt(from)} points`) + + (written ? ` · ${fmt(written)} decided, to apply` : ""); + if (!each && steps.steps && steps.steps.pairs) { steps.steps.pairs = {state: left || written ? "attention" : "done", line: left ? `${fmt(left)} waiting` : written ? `${fmt(written)} decided, to apply` : "all decided"}; rail(); } }; const load = async () => { if (rows.length) $("left").innerHTML = loading(); // another page of the queue; the first one waits under the pair's - const n = ++loads, x = await run("pairs", "list scored", {status: "open", from: String(from), page: String(page), count: String(count), record: $("record").value.trim()}); + const range = each ? {to: String(from), each: true} : {from: String(from)}; + const n = ++loads, x = await run("pairs", "list scored", {status: "open", ...range, page: String(page), count: String(count), record: $("record").value.trim()}); if (n !== loads) return; // the last filter's answer only: a pair is answered as it is shown if (x.event === "error") { $("left").innerHTML = banner(x); return; } rows = x.pairs; total = x.total; left = x.total - x.typed; i = Math.max(0, rows.findIndex((p) => !p.said)); tally(); draw(); show(); @@ -2230,10 +2235,10 @@

      Search

        ${item("lookup", "search", "Look up")} pairTable($("left"), rows, total, page, count, {compact: true, selected: i, onPick: (k) => { i = k; draw(); show(); }, onPage: (n) => { page = n; load(); }}); const show = () => { const p = rows[i]; - if (!p) { $("right").innerHTML = `
        ${icon("empty")}

        ${total ? "Pick a pair" : `No pair waits from ${fmt(from)} points`}

        `; where(); return; } + if (!p) { $("right").innerHTML = `
        ${icon("empty")}

        ${total ? "Pick a pair" : each ? `No pair waits below ${fmt(from)} points` : `No pair waits from ${fmt(from)} points`}

        `; where(); return; } $("right").innerHTML = `
        ${scope("pairs", `Pair ${fmt((page - 1) * count + i + 1)} of ${fmt(total)}`)}

        Same customer? ${p.said ? statusChip(p.status) : ""}

        -

        ${p.points.toFixed(1)} points (${esc(odds(p.points))})${foundBy(p) ? ` · found by ${esc(foundBy(p))}` : ""}${p.household ? ` ${HOUSEHOLD}` : ""}

        +

        ${p.points.toFixed(1)} points (${esc(odds(p.points))})${foundBy(p) ? ` · found by ${esc(foundBy(p))}` : ""}${p.like ? ` · one of ${plural(p.like, "pair")} like it` : ""}${p.household ? ` ${HOUSEHOLD}` : ""}

        ${keyHint([["M", "same"], ["N", "different"]])}

        Same: one entity once you apply your decisions. Different: kept apart for good.

        @@ -2280,6 +2285,7 @@

        Same customer? ${p.said ? statusChip(p.status) : ""}

        }; $("from").onchange = () => { const v = Number($("from").value); if ($("from").value.trim() === "" || !Number.isFinite(v)) { $("from").value = from; return; } from = v; try { localStorage.setItem("nayose.reviewFrom", String(v)); } catch {} page = 1; load(); }; // emptied: as it was, never 0 $("record").onchange = () => { page = 1; load(); }; + $("each").onchange = () => { each = $("each").checked; try { localStorage.setItem("nayose.reviewEach", each ? "1" : "0"); } catch {} page = 1; load(); }; $("apply").onclick = () => { $("apply").disabled = true; $("apply").querySelector("svg").outerHTML = spinner(); run("pairs", "apply decisions").then((e) => e.event === "error" ? ($("note").innerHTML = banner(e), $("apply").querySelector("svg").outerHTML = icon("check"), tally()) diff --git a/tests/test_ui_page.py b/tests/test_ui_page.py index 2f7bb9f..1c7b405 100644 --- a/tests/test_ui_page.py +++ b/tests/test_ui_page.py @@ -608,6 +608,12 @@ def other_job(): # another job writes to the workspace for a moment assert not other.is_alive() page.wait_for_function("() => document.querySelector('#written').textContent === '2'", timeout=15_000) assert not page.query_selector("#said .banner") and page.inner_text(".rail li.attention .sub") == f"{waiting - 2:,} waiting" + page.click("label:has(#each)") # below the floor, one pair of each pattern instead + page.wait_for_function("() => document.querySelector('#done-line').textContent.includes('one pair each')") + assert not page.query_selector("#right .banner") and page.inner_text(".rail li.attention .sub") == f"{waiting - 2:,} waiting" # the rail counts the queue still + assert "like it" in page.inner_text("#right .why") if page.query_selector("#right .why") else "No pair waits below" in page.inner_text("#right") + page.click("label:has(#each)") + page.wait_for_function(f"() => document.querySelector('#done-line').textContent.startsWith('{waiting - 2:,} pair')") entities = lambda: set(pd.read_parquet(ws / "gold.parquet").groupby("cluster_id")[uid].agg(frozenset)) before = entities() page.click("#merge") # merge without people, by their own conditions: no run diff --git a/tests/test_workspace.py b/tests/test_workspace.py index 51d5c62..4d70f14 100644 --- a/tests/test_workspace.py +++ b/tests/test_workspace.py @@ -607,6 +607,13 @@ def test_a_run_s_pairs_rows_and_entities_are_read_without_a_run_and_its_merge_co points = [x["points"] for x in one["pairs"] + two["pairs"]] assert one["total"] == len(index) and len(one["pairs"]) == 5 and points == sorted(points, reverse=True) # best first, across pages assert say("list", "scored", *at, "--status", "waiting", "--from", d["review_from"])[1]["total"] == sum(x["pairs"] for x in d["waiting"]) + below = ("--status", "open", "--to", 1000, "--count", 100_000) # every open pair: on this file, patterns repeat above the floor only + _, every = say("list", "scored", *at, *below) + _, kinds = say("list", "scored", *at, *below, "--each") # one of each pattern nobody is asked about + pattern = lambda x: tuple(sorted((c, v["level"]) for c, v in x["compared"].items())) + assert every["total"] > kinds["total"] == len(kinds["pairs"]) == len({pattern(x) for x in kinds["pairs"]}) == len({pattern(x) for x in every["pairs"]}) + assert sum(x["like"] for x in kinds["pairs"]) == every["total"] and [x["like"] for x in kinds["pairs"]] == sorted((x["like"] for x in kinds["pairs"]), reverse=True) + assert "like" not in every["pairs"][0] best = one["pairs"][0] assert set(best["compared"]) == {c.name for c in p.fs.model.comparisons} # each comparison's level and points _, rows = say("show", "records", best["first"], best["second"], "nope", *at)