feat(platform): add the notification inbox and deterministic match search

This commit is contained in:
shira committed 2026-10-09 13:14:46 +03:00
1 parent 5edff21d2d
commit 0b11021b16
169 files changed
+17083 -443

No files matched your search

+45
View File
@@ -103,3 +103,48 @@ WHERE
AND fact.kind = 'measurement'
AND fact.visibility = 'visible'
ORDER BY skill.skill_code, fact.occurred_at, fact.id;
-- The same organization read for a whole candidate set, so a search reads the
-- evidence of every listed candidate in one statement. The pairs come from the
-- caller as two parallel arrays, one row per candidate and category of the card
-- that was just projected. The statement repeats every barrier of the single
-- read: the effective publication view, NOT EXISTS over the candidates that
-- hide the organization, the categories field, and only visible measurements.
-- The candidate identifier is returned for the caller to group by and never
-- leaves the server; the other columns are the same allowlist.
-- name: ListOrganizationVisibleEvidenceBatch :many
SELECT DISTINCT ON (wanted.candidate_id, skill.skill_code)
wanted.candidate_id::uuid AS candidate_id,
skill.skill_code AS skill,
fact.grade,
fact.trust,
fact.basis,
fact.calibration_status,
extract(YEAR FROM fact.occurred_at AT TIME ZONE 'UTC')::integer AS observed_year
FROM (
SELECT
candidate_ids.candidate_id,
wanted_categories.category
FROM unnest(sqlc.arg(candidate_ids)::uuid []) WITH ORDINALITY AS candidate_ids (candidate_id, position)
INNER JOIN unnest(sqlc.arg(categories)::text []) WITH ORDINALITY AS wanted_categories (category, position)
ON candidate_ids.position = wanted_categories.position
) AS wanted
INNER JOIN candidate_effective_publications AS effective
ON wanted.candidate_id = effective.user_id
INNER JOIN skill_evidence_facts AS fact
ON effective.user_id = fact.candidate_id
INNER JOIN skill_evidence_skills AS skill
ON fact.id = skill.fact_id
WHERE
'categories' = any(effective.fields)
AND (skill.skill_code || '/' || fact.grade) = wanted.category
AND fact.kind = 'measurement'
AND fact.visibility = 'visible'
AND NOT EXISTS (
SELECT 1
FROM candidate_hidden_organizations AS hidden
WHERE
hidden.user_id = effective.user_id
AND hidden.organization_id = sqlc.arg(organization_id)
)
ORDER BY wanted.candidate_id, skill.skill_code, fact.occurred_at, fact.id;