feat(assessment): assign the demonstration category and keep result history
This commit is contained in:
1 parent
b3c6dc870b
commit
8277133712
61 files changed
+4338
-268
No files matched your search
@@ -21,7 +21,8 @@ INSERT INTO assessment_attempt_results (
|
||||
-- Returns both immutable result versions. NULL category fields identify a
|
||||
-- legacy v1 record and must not be reconstructed from current state.
|
||||
-- name: GetAssessmentAttemptResultHistoryEntry :one
|
||||
SELECT schema_version, result_snapshot::text, category_decision::text, current_confirmed_grade
|
||||
SELECT schema_version, result_snapshot::text,
|
||||
COALESCE(category_decision::text, '')::text AS category_decision, current_confirmed_grade
|
||||
FROM assessment_attempt_results
|
||||
WHERE user_id = sqlc.arg(user_id) AND attempt_id = sqlc.arg(attempt_id);
|
||||
|
||||
@@ -29,7 +30,7 @@ WHERE user_id = sqlc.arg(user_id) AND attempt_id = sqlc.arg(attempt_id);
|
||||
-- applies the keyset to the same stable order and fetches one extra row.
|
||||
-- name: ListCandidateAssessmentResults :many
|
||||
SELECT attempt_id, user_id, schema_version, result_snapshot::text,
|
||||
category_decision::text, current_confirmed_grade, decided_at
|
||||
COALESCE(category_decision::text, '')::text AS category_decision, current_confirmed_grade, decided_at
|
||||
FROM assessment_attempt_results
|
||||
WHERE user_id = sqlc.arg(user_id)
|
||||
AND kind IN ('root', 'corrective')
|
||||
@@ -69,8 +70,10 @@ WHERE review.opening_id = sqlc.arg(opening_id)
|
||||
AND opening.policy_version_id = sqlc.arg(grading_policy_version_id);
|
||||
|
||||
-- The application accepts only a validated immutable review snapshot. The
|
||||
-- trigger independently checks the source opening, manifest and policy.
|
||||
-- name: InsertSyntheticCategoryReview :exec
|
||||
-- trigger independently checks the source opening, manifest and policy. A
|
||||
-- concurrent or repeated attestation of the same exact source inserts nothing,
|
||||
-- and the caller reads the stored one.
|
||||
-- name: InsertSyntheticCategoryReview :execrows
|
||||
INSERT INTO assessment_synthetic_category_reviews (
|
||||
id, opening_id, category, source, opening_manifest_sha256,
|
||||
product_policy_version_id, product_policy_version, reviewed_by, reviewed_at
|
||||
@@ -78,10 +81,13 @@ INSERT INTO assessment_synthetic_category_reviews (
|
||||
sqlc.arg(id), sqlc.arg(opening_id), sqlc.arg(category), sqlc.arg(source),
|
||||
sqlc.arg(opening_manifest_sha256), sqlc.arg(product_policy_version_id),
|
||||
sqlc.arg(product_policy_version), sqlc.arg(reviewed_by), sqlc.arg(reviewed_at)
|
||||
);
|
||||
)
|
||||
ON CONFLICT ON CONSTRAINT assessment_synthetic_category_reviews_exact_source_key DO NOTHING;
|
||||
|
||||
-- Only strict grade upgrades replace the current row. The trigger enforces
|
||||
-- the same monotonic rule as a final guard against adapter mistakes.
|
||||
-- the same monotonic rule as a final guard against adapter mistakes. The
|
||||
-- grading policy is read from the immutable opening, and the guard trigger
|
||||
-- compares it with the policy captured in the assigned result.
|
||||
-- name: SaveCandidateAssessmentCategory :execrows
|
||||
INSERT INTO candidate_assessment_categories (
|
||||
candidate_id, specialization, grade, source_attempt_id, source_review_id,
|
||||
@@ -90,7 +96,12 @@ INSERT INTO candidate_assessment_categories (
|
||||
) VALUES (
|
||||
sqlc.arg(candidate_id), sqlc.arg(specialization), sqlc.arg(grade), sqlc.arg(source_attempt_id),
|
||||
sqlc.arg(source_review_id), sqlc.arg(product_policy_version_id), sqlc.arg(product_policy_version),
|
||||
sqlc.arg(grading_policy_version_id), sqlc.arg(opening_id), sqlc.arg(opening_manifest_sha256),
|
||||
(
|
||||
SELECT opening.policy_version_id
|
||||
FROM assessment_category_openings AS opening
|
||||
WHERE opening.id = sqlc.arg(opening_id)
|
||||
),
|
||||
sqlc.arg(opening_id), sqlc.arg(opening_manifest_sha256),
|
||||
sqlc.arg(source), sqlc.arg(calibration_status), sqlc.arg(assigned_at)
|
||||
)
|
||||
ON CONFLICT (candidate_id, specialization) DO UPDATE SET
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
-- candidates hidden from this organization before any profile value is read.
|
||||
-- The projection reads only stack, declared role, and experience dates. It
|
||||
-- deliberately excludes names, contacts, salary, location, soft skills,
|
||||
-- employer names, summaries, and imported excerpts.
|
||||
-- employer names, summaries, and imported excerpts. The only assessment data
|
||||
-- is the current category (specialization and grade) of the separate current
|
||||
-- category table; it carries no attempt, score, review, policy, or history.
|
||||
-- name: ListVisibleCandidateViewSources :many
|
||||
SELECT
|
||||
effective.user_id,
|
||||
@@ -47,7 +49,18 @@ SELECT
|
||||
WHERE overlap.user_id = effective.user_id
|
||||
),
|
||||
'[]'::text
|
||||
) AS parallel_period_acknowledgements
|
||||
) AS parallel_period_acknowledgements,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT jsonb_agg(
|
||||
jsonb_build_object('specialization', category.specialization, 'grade', category.grade)
|
||||
ORDER BY category.specialization
|
||||
)::text
|
||||
FROM candidate_assessment_categories AS category
|
||||
WHERE category.candidate_id = effective.user_id
|
||||
),
|
||||
'[]'::text
|
||||
) AS confirmed_categories
|
||||
FROM candidate_effective_publications AS effective
|
||||
LEFT JOIN candidate_profile_claims AS claim
|
||||
ON claim.user_id = effective.user_id
|
||||
@@ -170,7 +183,18 @@ SELECT
|
||||
WHERE overlap.user_id = effective.user_id
|
||||
),
|
||||
'[]'::text
|
||||
) AS parallel_period_acknowledgements
|
||||
) AS parallel_period_acknowledgements,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT jsonb_agg(
|
||||
jsonb_build_object('specialization', category.specialization, 'grade', category.grade)
|
||||
ORDER BY category.specialization
|
||||
)::text
|
||||
FROM candidate_assessment_categories AS category
|
||||
WHERE category.candidate_id = effective.user_id
|
||||
),
|
||||
'[]'::text
|
||||
) AS confirmed_categories
|
||||
FROM candidate_effective_publications AS effective
|
||||
LEFT JOIN candidate_profile_claims AS claim
|
||||
ON claim.user_id = effective.user_id
|
||||
|
||||
Reference in new issue
Block a user