Keep a remote listing and an office listing two roles in the per-place fold, since the kept role takes a copy's places and not its remote and the fetch gate then rejected the one behind the other
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f774b5147
commit
b4774f1da9
3 files changed
+31
-7
No files matched your search
+13
-4
@@ -82,6 +82,8 @@ class Copy:
|
||||
text: str = ""
|
||||
#: The link that opens this row on its host.
|
||||
url: str = ""
|
||||
#: Whether the row is a remote role (`roles.remote` is 'remote').
|
||||
remote: bool = False
|
||||
|
||||
|
||||
def _country(c: Copy) -> str:
|
||||
@@ -191,9 +193,15 @@ def fold(rows: Iterable[Copy]) -> Folded:
|
||||
|
||||
Within a `(company_key, title_key)` the kept rows of `assign` are grouped
|
||||
again, in `keep_order`: a row joins the first group whose members are all
|
||||
of its host and `similar` to it. Only a row with a link can be folded, as
|
||||
its link is what the kept role keeps. Every row of a merged group points
|
||||
at its first row, the rows that pointed at a folded one included."""
|
||||
of its host, `similar` to it and remote as it is or not. Only a row with
|
||||
a link can be folded, as its link is what the kept role keeps. Every row
|
||||
of a merged group points at its first row, the rows that pointed at a
|
||||
folded one included.
|
||||
|
||||
A remote listing and an office listing stay two roles: the kept role
|
||||
takes a copy's places and not its remote, so the fetch gate, which reads
|
||||
a remote role by its area, would reject the remote listing with an
|
||||
office role elsewhere, and the office one with a remote role elsewhere."""
|
||||
rows = list(rows)
|
||||
result = assign(rows)
|
||||
by_uid = {r.uid: r for r in rows}
|
||||
@@ -207,7 +215,8 @@ def fold(rows: Iterable[Copy]) -> Folded:
|
||||
groups: list[list[Copy]] = []
|
||||
for row in sorted(part, key=keep_order):
|
||||
for group in groups:
|
||||
if all(m.host == row.host and similar(m.text, row.text) for m in group):
|
||||
if all(m.host == row.host and m.remote == row.remote
|
||||
and similar(m.text, row.text) for m in group):
|
||||
group.append(row)
|
||||
break
|
||||
else:
|
||||
|
||||
@@ -548,7 +548,8 @@ def rebuild_dupes(conn: sqlite3.Connection) -> DupeCounts:
|
||||
|
||||
A copy the host published for another place (`dupes.Folded.placed`)
|
||||
leaves its places on the kept role as `role_places` rows with the copy's
|
||||
link, see `_sync_copy_places`."""
|
||||
link, see `_sync_copy_places`. Its remote stays its own, which is why a
|
||||
remote listing is never folded into an office one (`dupes.fold`)."""
|
||||
# Migration 18 runs this on a file that has no `teaser` and no
|
||||
# `role_places` yet: there it groups as before and folds no places.
|
||||
current = any(r[1] == "teaser" for r in conn.execute("PRAGMA table_info(roles)"))
|
||||
@@ -556,7 +557,7 @@ def rebuild_dupes(conn: sqlite3.Connection) -> DupeCounts:
|
||||
rows = conn.execute(
|
||||
f"""SELECT uid, company_key, title_key, country, place, {_HOST} AS host,
|
||||
description != '' AS described, posted_at,
|
||||
SUBSTR({text}, 1, {dupes.TEXT_CHARS}), original_url
|
||||
SUBSTR({text}, 1, {dupes.TEXT_CHARS}), original_url, remote = 'remote'
|
||||
FROM roles
|
||||
WHERE closed_at IS NULL AND company_key != ''
|
||||
AND (company_key, title_key) IN (
|
||||
@@ -567,7 +568,7 @@ def rebuild_dupes(conn: sqlite3.Connection) -> DupeCounts:
|
||||
folded = made(
|
||||
dupes.Copy(uid=r[0], company_key=r[1], title_key=r[2], country=r[3], place=r[4],
|
||||
host=r[5], has_description=bool(r[6]), posted_at=r[7] or None,
|
||||
text=r[8] or "", url=r[9] or "")
|
||||
text=r[8] or "", url=r[9] or "", remote=bool(r[10]))
|
||||
for r in rows)
|
||||
new = folded.dup_of
|
||||
old: dict[str, str | None] = dict.fromkeys(new)
|
||||
|
||||
Reference in new issue
Block a user