feat(platform): add the notification inbox and deterministic match search
This commit is contained in:
1 parent
5edff21d2d
commit
0b11021b16
169 files changed
+17083
-443
No files matched your search
@@ -12,7 +12,9 @@ import (
|
||||
var (
|
||||
evidenceTableName = regexp.MustCompile(`(?i)\bskill_evidence_(facts|skills)\b`)
|
||||
// evidenceReaders are the only queries that may name the evidence tables.
|
||||
evidenceReaders = []string{"ListCandidateEvidenceFacts", "ListCandidatePreviewEvidence", "ListOrganizationVisibleEvidence"}
|
||||
evidenceReaders = []string{
|
||||
"ListCandidateEvidenceFacts", "ListCandidatePreviewEvidence", "ListOrganizationVisibleEvidence", "ListOrganizationVisibleEvidenceBatch",
|
||||
}
|
||||
// evidenceForbiddenSources are tables whose content must never reach the
|
||||
// evidence reads: raw answers and items, results with their scores,
|
||||
// attempts, signals, and the anti-cheat review band.
|
||||
@@ -123,3 +125,41 @@ func TestOrganizationEvidenceReadUsesTheVisibilityBarrier(t *testing.T) {
|
||||
t.Errorf("organization evidence query reads the publication table directly: %s", statement)
|
||||
}
|
||||
}
|
||||
|
||||
// The batch read repeats every barrier of the single organization read, and
|
||||
// the match-search queries name no evidence table.
|
||||
func TestOrganizationEvidenceBatchReadRepeatsTheVisibilityBarrier(t *testing.T) {
|
||||
statements := evidenceStatements(t)
|
||||
statement := statements["ListOrganizationVisibleEvidenceBatch"]
|
||||
if statement == "" {
|
||||
t.Fatal("the batch organization evidence query is missing")
|
||||
}
|
||||
for _, required := range []string{
|
||||
"inner join candidate_effective_publications as effective",
|
||||
"from candidate_hidden_organizations as hidden",
|
||||
"not exists",
|
||||
"hidden.organization_id = sqlc.arg(organization_id)",
|
||||
"'categories' = any(effective.fields)",
|
||||
"fact.visibility = 'visible'",
|
||||
"fact.kind = 'measurement'",
|
||||
"(skill.skill_code || '/' || fact.grade) = wanted.category",
|
||||
} {
|
||||
if !strings.Contains(statement, required) {
|
||||
t.Errorf("batch organization evidence query lacks %q: %s", required, statement)
|
||||
}
|
||||
}
|
||||
if strings.Contains(statement, "candidate_publications") && !strings.Contains(statement, "candidate_effective_publications") {
|
||||
t.Errorf("batch organization evidence query reads the publication table directly: %s", statement)
|
||||
}
|
||||
for _, private := range []string{"fact.id,", "event_id", "result_id", "fact.visibility,", "occurred_at,"} {
|
||||
selected := statement[len("select"):strings.Index(statement, " from (")]
|
||||
if strings.Contains(selected, private) {
|
||||
t.Errorf("batch organization evidence query selects %q: %s", private, selected)
|
||||
}
|
||||
}
|
||||
for name, search := range statements {
|
||||
if strings.HasPrefix(name, "CountReal") && evidenceTableName.MatchString(search) {
|
||||
t.Errorf("%s names an evidence table: %s", name, search)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user