fix(assessment): return confirmed categories with their basis and label demonstration categories

This commit is contained in:
shira committed 2026-10-09 21:24:24 +03:00
1 parent 623d41b969
commit d4903a3796
77 files changed
+1441 -288

No files matched your search

@@ -244,6 +244,49 @@ func (q *Queries) InsertSyntheticCategoryReview(ctx context.Context, arg InsertS
return result.RowsAffected(), nil
}
const listCandidateAssessmentCategories = `-- name: ListCandidateAssessmentCategories :many
SELECT candidate_id, specialization, grade, source_attempt_id, source_review_id,
product_policy_version_id, product_policy_version, grading_policy_version_id,
opening_id, opening_manifest_sha256, source, calibration_status, assigned_at
FROM candidate_assessment_categories
WHERE candidate_id = $1
ORDER BY specialization
`
func (q *Queries) ListCandidateAssessmentCategories(ctx context.Context, candidateID pgtype.UUID) ([]CandidateAssessmentCategory, error) {
rows, err := q.db.Query(ctx, listCandidateAssessmentCategories, candidateID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []CandidateAssessmentCategory
for rows.Next() {
var i CandidateAssessmentCategory
if err := rows.Scan(
&i.CandidateID,
&i.Specialization,
&i.Grade,
&i.SourceAttemptID,
&i.SourceReviewID,
&i.ProductPolicyVersionID,
&i.ProductPolicyVersion,
&i.GradingPolicyVersionID,
&i.OpeningID,
&i.OpeningManifestSha256,
&i.Source,
&i.CalibrationStatus,
&i.AssignedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listCandidateAssessmentResults = `-- name: ListCandidateAssessmentResults :many
SELECT attempt_id, user_id, schema_version, result_snapshot::text,
COALESCE(category_decision::text, '')::text AS category_decision, current_confirmed_grade, decided_at
@@ -57,7 +57,11 @@ SELECT
COALESCE(
(
SELECT jsonb_agg(
jsonb_build_object('specialization', category.specialization, 'grade', category.grade)
jsonb_build_object(
'specialization', category.specialization,
'grade', category.grade,
'source', category.source
)
ORDER BY category.specialization
)::text
FROM candidate_assessment_categories AS category
@@ -286,7 +290,11 @@ SELECT
COALESCE(
(
SELECT jsonb_agg(
jsonb_build_object('specialization', category.specialization, 'grade', category.grade)
jsonb_build_object(
'specialization', category.specialization,
'grade', category.grade,
'source', category.source
)
ORDER BY category.specialization
)::text
FROM candidate_assessment_categories AS category
@@ -656,6 +656,7 @@ type Querier interface {
ListAssessmentOriginMarks(ctx context.Context, attemptID pgtype.UUID) ([]AssessmentAttemptOriginMark, error)
// Reads the exact family membership pinned by a training binding.
ListAssessmentTrainingBindingFamilies(ctx context.Context, bindingID pgtype.UUID) ([]ListAssessmentTrainingBindingFamiliesRow, error)
ListCandidateAssessmentCategories(ctx context.Context, candidateID pgtype.UUID) ([]CandidateAssessmentCategory, error)
// The caller validates and signs an opaque owner-bound cursor. This query
// applies the keyset to the same stable order and fetches one extra row.
ListCandidateAssessmentResults(ctx context.Context, arg ListCandidateAssessmentResultsParams) ([]ListCandidateAssessmentResultsRow, error)