Merge branch 'r2-backend'

# Conflicts:
#	app/storage/schema.py
This commit is contained in:
Wolf committed 2026-09-29 15:22:03 +02:00
commit 562fa3ab09
15 files changed
+924 -157

No files matched your search

+15 -2
View File
@@ -1094,11 +1094,24 @@ class Store:
"""One agent's stance on a company: -1 hidden, 0 neutral, 1 liked, 2
favourite. 0 deletes the row, since no row means neutral. Returns the
company with this agent's affinity. Raises ValueError for another
value and KeyError for an unknown company or agent."""
value and KeyError for an unknown company or agent.
A key with roles and no company row, an employer known only from a
search, gets a row here holding only its key and the name its roles
give it, the most frequent one: nothing else can be judged without
one. It has no board, `ats`, `careers_url` or `domain`, which is how
the Companies list tells it from a followed company."""
_check_affinity(affinity)
with self.transaction() as conn:
self._known(conn, "companies", "key", key)
self._known(conn, "agents", "id", agent_id)
if conn.execute("SELECT 1 FROM companies WHERE key=?", (key,)).fetchone() is None:
named = conn.execute(
"""SELECT company FROM roles WHERE company_key=? AND company<>''
GROUP BY company ORDER BY count(*) DESC, max(last_seen) DESC
LIMIT 1""", (key,)).fetchone()
if named is None:
raise KeyError(key)
self._insert_company(conn, key, named[0], {})
if affinity == 0:
conn.execute("DELETE FROM agent_companies WHERE agent_id=? AND company_key=?",
(agent_id, key))