121 lines
3.5 KiB
Go
121 lines
3.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: support_rubrics.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const resolveCurrentSupportCaseRubrics = `-- name: ResolveCurrentSupportCaseRubrics :many
|
|
WITH current_openings AS (
|
|
SELECT DISTINCT ON (category)
|
|
id,
|
|
category,
|
|
policy_version_id,
|
|
required_families
|
|
FROM assessment_category_openings
|
|
ORDER BY category, opened_at DESC, id DESC
|
|
), current_policy AS (
|
|
SELECT id, version
|
|
FROM policy_versions
|
|
WHERE policy_key = 'product' AND effective_at <= statement_timestamp()
|
|
ORDER BY version DESC
|
|
LIMIT 1
|
|
)
|
|
SELECT
|
|
opening.id AS opening_id,
|
|
opening.category,
|
|
opening.policy_version_id,
|
|
opening.required_families,
|
|
COALESCE((
|
|
SELECT count(DISTINCT family.family_key)::integer
|
|
FROM assessment_families AS family
|
|
WHERE family.category = opening.category AND family.lifecycle = 'published'
|
|
), 0)::integer AS published_count,
|
|
policy.id AS effective_policy_id,
|
|
policy.version AS effective_policy_version,
|
|
binding.specialization,
|
|
binding.grade,
|
|
binding.task_languages,
|
|
binding.published_manifest_sha256,
|
|
COALESCE((
|
|
SELECT jsonb_agg(
|
|
jsonb_build_object(
|
|
'family_key', family.family_key,
|
|
'version', family.version,
|
|
'content_sha256', encode(family.content_sha256, 'hex')
|
|
) ORDER BY family.family_key, family.version
|
|
)
|
|
FROM assessment_families AS family
|
|
WHERE family.category = opening.category AND family.lifecycle = 'published'
|
|
), '[]'::jsonb)::text AS published_manifest
|
|
FROM current_openings AS opening
|
|
JOIN assessment_category_catalog_bindings AS binding
|
|
ON binding.opening_id = opening.id
|
|
LEFT JOIN current_policy AS policy ON true
|
|
WHERE binding.specialization = $1
|
|
AND binding.grade = $2
|
|
ORDER BY opening.category
|
|
`
|
|
|
|
type ResolveCurrentSupportCaseRubricsParams struct {
|
|
Specialization string
|
|
Grade string
|
|
}
|
|
|
|
type ResolveCurrentSupportCaseRubricsRow struct {
|
|
OpeningID pgtype.UUID
|
|
Category string
|
|
PolicyVersionID pgtype.UUID
|
|
RequiredFamilies int32
|
|
PublishedCount int32
|
|
EffectivePolicyID pgtype.UUID
|
|
EffectivePolicyVersion pgtype.Int4
|
|
Specialization string
|
|
Grade string
|
|
TaskLanguages []string
|
|
PublishedManifestSha256 []byte
|
|
PublishedManifest string
|
|
}
|
|
|
|
// Lists every current reviewed category binding for one exact public target.
|
|
// Manual support cases have no task-language selector, so the use case must
|
|
// accept a rubric only when one distinct current opening matches.
|
|
func (q *Queries) ResolveCurrentSupportCaseRubrics(ctx context.Context, arg ResolveCurrentSupportCaseRubricsParams) ([]ResolveCurrentSupportCaseRubricsRow, error) {
|
|
rows, err := q.db.Query(ctx, resolveCurrentSupportCaseRubrics, arg.Specialization, arg.Grade)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ResolveCurrentSupportCaseRubricsRow
|
|
for rows.Next() {
|
|
var i ResolveCurrentSupportCaseRubricsRow
|
|
if err := rows.Scan(
|
|
&i.OpeningID,
|
|
&i.Category,
|
|
&i.PolicyVersionID,
|
|
&i.RequiredFamilies,
|
|
&i.PublishedCount,
|
|
&i.EffectivePolicyID,
|
|
&i.EffectivePolicyVersion,
|
|
&i.Specialization,
|
|
&i.Grade,
|
|
&i.TaskLanguages,
|
|
&i.PublishedManifestSha256,
|
|
&i.PublishedManifest,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|