fix(assessment): return confirmed categories with their basis and label demonstration categories
This commit is contained in:
1 parent
623d41b969
commit
d4903a3796
77 files changed
+1441
-288
No files matched your search
@@ -10300,6 +10300,10 @@ func (s *AssessmentSpecializationAvailability) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("confirmed_grade")
|
||||
s.ConfirmedGrade.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("confirmed_basis")
|
||||
s.ConfirmedBasis.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("active_attempt_id")
|
||||
s.ActiveAttemptID.Encode(e)
|
||||
@@ -10314,11 +10318,12 @@ func (s *AssessmentSpecializationAvailability) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfAssessmentSpecializationAvailability = [4]string{
|
||||
var jsonFieldsNameOfAssessmentSpecializationAvailability = [5]string{
|
||||
0: "specialization",
|
||||
1: "confirmed_grade",
|
||||
2: "active_attempt_id",
|
||||
3: "grades",
|
||||
2: "confirmed_basis",
|
||||
3: "active_attempt_id",
|
||||
4: "grades",
|
||||
}
|
||||
|
||||
// Decode decodes AssessmentSpecializationAvailability from json.
|
||||
@@ -10350,8 +10355,18 @@ func (s *AssessmentSpecializationAvailability) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"confirmed_grade\"")
|
||||
}
|
||||
case "active_attempt_id":
|
||||
case "confirmed_basis":
|
||||
requiredBitSet[0] |= 1 << 2
|
||||
if err := func() error {
|
||||
if err := s.ConfirmedBasis.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"confirmed_basis\"")
|
||||
}
|
||||
case "active_attempt_id":
|
||||
requiredBitSet[0] |= 1 << 3
|
||||
if err := func() error {
|
||||
if err := s.ActiveAttemptID.Decode(d); err != nil {
|
||||
return err
|
||||
@@ -10361,7 +10376,7 @@ func (s *AssessmentSpecializationAvailability) Decode(d *jx.Decoder) error {
|
||||
return errors.Wrap(err, "decode field \"active_attempt_id\"")
|
||||
}
|
||||
case "grades":
|
||||
requiredBitSet[0] |= 1 << 3
|
||||
requiredBitSet[0] |= 1 << 4
|
||||
if err := func() error {
|
||||
s.Grades = make([]AssessmentGradeAvailability, 0)
|
||||
if err := d.Arr(func(d *jx.Decoder) error {
|
||||
@@ -10388,7 +10403,7 @@ func (s *AssessmentSpecializationAvailability) Decode(d *jx.Decoder) error {
|
||||
// Validate required fields.
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [1]uint8{
|
||||
0b00001111,
|
||||
0b00011111,
|
||||
} {
|
||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||
// Mask only required fields and check equality to mask using XOR.
|
||||
@@ -13612,12 +13627,17 @@ func (s *CardCategory) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("strength")
|
||||
s.Strength.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("basis")
|
||||
s.Basis.Encode(e)
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfCardCategory = [3]string{
|
||||
var jsonFieldsNameOfCardCategory = [4]string{
|
||||
0: "specialization",
|
||||
1: "grade",
|
||||
2: "strength",
|
||||
3: "basis",
|
||||
}
|
||||
|
||||
// Decode decodes CardCategory from json.
|
||||
@@ -13659,6 +13679,16 @@ func (s *CardCategory) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"strength\"")
|
||||
}
|
||||
case "basis":
|
||||
requiredBitSet[0] |= 1 << 3
|
||||
if err := func() error {
|
||||
if err := s.Basis.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"basis\"")
|
||||
}
|
||||
default:
|
||||
return errors.Errorf("unexpected field %q", k)
|
||||
}
|
||||
@@ -13669,7 +13699,7 @@ func (s *CardCategory) Decode(d *jx.Decoder) error {
|
||||
// Validate required fields.
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [1]uint8{
|
||||
0b00000111,
|
||||
0b00001111,
|
||||
} {
|
||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||
// Mask only required fields and check equality to mask using XOR.
|
||||
@@ -29198,11 +29228,16 @@ func (s *MatchCategory) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("grade")
|
||||
s.Grade.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("basis")
|
||||
s.Basis.Encode(e)
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfMatchCategory = [2]string{
|
||||
var jsonFieldsNameOfMatchCategory = [3]string{
|
||||
0: "specialization",
|
||||
1: "grade",
|
||||
2: "basis",
|
||||
}
|
||||
|
||||
// Decode decodes MatchCategory from json.
|
||||
@@ -29234,6 +29269,16 @@ func (s *MatchCategory) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"grade\"")
|
||||
}
|
||||
case "basis":
|
||||
requiredBitSet[0] |= 1 << 2
|
||||
if err := func() error {
|
||||
if err := s.Basis.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"basis\"")
|
||||
}
|
||||
default:
|
||||
return errors.Errorf("unexpected field %q", k)
|
||||
}
|
||||
@@ -29244,7 +29289,7 @@ func (s *MatchCategory) Decode(d *jx.Decoder) error {
|
||||
// Validate required fields.
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [1]uint8{
|
||||
0b00000011,
|
||||
0b00000111,
|
||||
} {
|
||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||
// Mask only required fields and check equality to mask using XOR.
|
||||
@@ -39018,6 +39063,50 @@ func (s *NilEmailAddress) UnmarshalJSON(data []byte) error {
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode encodes EvidenceBasis as json.
|
||||
func (o NilEvidenceBasis) Encode(e *jx.Encoder) {
|
||||
if o.Null {
|
||||
e.Null()
|
||||
return
|
||||
}
|
||||
e.Str(string(o.Value))
|
||||
}
|
||||
|
||||
// Decode decodes EvidenceBasis from json.
|
||||
func (o *NilEvidenceBasis) Decode(d *jx.Decoder) error {
|
||||
if o == nil {
|
||||
return errors.New("invalid: unable to decode NilEvidenceBasis to nil")
|
||||
}
|
||||
if d.Next() == jx.Null {
|
||||
if err := d.Null(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var v EvidenceBasis
|
||||
o.Value = v
|
||||
o.Null = true
|
||||
return nil
|
||||
}
|
||||
o.Null = false
|
||||
if err := o.Value.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements stdjson.Marshaler.
|
||||
func (s NilEvidenceBasis) MarshalJSON() ([]byte, error) {
|
||||
e := jx.Encoder{}
|
||||
s.Encode(&e)
|
||||
return e.Bytes(), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
||||
func (s *NilEvidenceBasis) UnmarshalJSON(data []byte) error {
|
||||
d := jx.DecodeBytes(data)
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode encodes float64 as json.
|
||||
func (o NilFloat64) Encode(e *jx.Encoder) {
|
||||
if o.Null {
|
||||
@@ -49486,6 +49575,10 @@ func (s *ProfileConfirmedCategory) encodeFields(e *jx.Encoder) {
|
||||
e.FieldStart("grade")
|
||||
s.Grade.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("basis")
|
||||
s.Basis.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("confirmed_at")
|
||||
s.ConfirmedAt.Encode(e)
|
||||
@@ -49496,11 +49589,12 @@ func (s *ProfileConfirmedCategory) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfProfileConfirmedCategory = [4]string{
|
||||
var jsonFieldsNameOfProfileConfirmedCategory = [5]string{
|
||||
0: "specialization",
|
||||
1: "grade",
|
||||
2: "confirmed_at",
|
||||
3: "attempt_id",
|
||||
2: "basis",
|
||||
3: "confirmed_at",
|
||||
4: "attempt_id",
|
||||
}
|
||||
|
||||
// Decode decodes ProfileConfirmedCategory from json.
|
||||
@@ -49532,8 +49626,18 @@ func (s *ProfileConfirmedCategory) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"grade\"")
|
||||
}
|
||||
case "confirmed_at":
|
||||
case "basis":
|
||||
requiredBitSet[0] |= 1 << 2
|
||||
if err := func() error {
|
||||
if err := s.Basis.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"basis\"")
|
||||
}
|
||||
case "confirmed_at":
|
||||
requiredBitSet[0] |= 1 << 3
|
||||
if err := func() error {
|
||||
if err := s.ConfirmedAt.Decode(d); err != nil {
|
||||
return err
|
||||
@@ -49543,7 +49647,7 @@ func (s *ProfileConfirmedCategory) Decode(d *jx.Decoder) error {
|
||||
return errors.Wrap(err, "decode field \"confirmed_at\"")
|
||||
}
|
||||
case "attempt_id":
|
||||
requiredBitSet[0] |= 1 << 3
|
||||
requiredBitSet[0] |= 1 << 4
|
||||
if err := func() error {
|
||||
v, err := json.DecodeUUID(d)
|
||||
s.AttemptID = v
|
||||
@@ -49564,7 +49668,7 @@ func (s *ProfileConfirmedCategory) Decode(d *jx.Decoder) error {
|
||||
// Validate required fields.
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [1]uint8{
|
||||
0b00001111,
|
||||
0b00011111,
|
||||
} {
|
||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||
// Mask only required fields and check equality to mask using XOR.
|
||||
|
||||
@@ -5395,6 +5395,10 @@ type AssessmentSpecializationAvailability struct {
|
||||
Specialization SpecializationCode `json:"specialization"`
|
||||
// Currently confirmed grade of the specialization, or null.
|
||||
ConfirmedGrade NilGradeCode `json:"confirmed_grade"`
|
||||
// What the confirmed grade rests on, or null exactly when `confirmed_grade` is null. `synthetic_demo`
|
||||
// marks a demonstration category, which is not a validated measurement and must not be shown as a real
|
||||
// confirmation.
|
||||
ConfirmedBasis NilEvidenceBasis `json:"confirmed_basis"`
|
||||
// Identifier of the active attempt of the specialization, or null.
|
||||
ActiveAttemptID NilUUID `json:"active_attempt_id"`
|
||||
// Every grade of the scale in ascending order.
|
||||
@@ -5411,6 +5415,11 @@ func (s *AssessmentSpecializationAvailability) GetConfirmedGrade() NilGradeCode
|
||||
return s.ConfirmedGrade
|
||||
}
|
||||
|
||||
// GetConfirmedBasis returns the value of ConfirmedBasis.
|
||||
func (s *AssessmentSpecializationAvailability) GetConfirmedBasis() NilEvidenceBasis {
|
||||
return s.ConfirmedBasis
|
||||
}
|
||||
|
||||
// GetActiveAttemptID returns the value of ActiveAttemptID.
|
||||
func (s *AssessmentSpecializationAvailability) GetActiveAttemptID() NilUUID {
|
||||
return s.ActiveAttemptID
|
||||
@@ -5431,6 +5440,11 @@ func (s *AssessmentSpecializationAvailability) SetConfirmedGrade(val NilGradeCod
|
||||
s.ConfirmedGrade = val
|
||||
}
|
||||
|
||||
// SetConfirmedBasis sets the value of ConfirmedBasis.
|
||||
func (s *AssessmentSpecializationAvailability) SetConfirmedBasis(val NilEvidenceBasis) {
|
||||
s.ConfirmedBasis = val
|
||||
}
|
||||
|
||||
// SetActiveAttemptID sets the value of ActiveAttemptID.
|
||||
func (s *AssessmentSpecializationAvailability) SetActiveAttemptID(val NilUUID) {
|
||||
s.ActiveAttemptID = val
|
||||
@@ -7030,13 +7044,15 @@ func (s *CardAccessListHeaders) SetResponse(val CardAccessList) {
|
||||
|
||||
func (*CardAccessListHeaders) listMyCardAccessHistoryRes() {}
|
||||
|
||||
// A category confirmed by assessment results, as the card shows it.
|
||||
// A category confirmed by assessment results, as the card shows it. `basis` says what the grade rests
|
||||
// on; `synthetic_demo` marks a demonstration category, which is never a standard confirmation.
|
||||
// Ref: #/components/schemas/CardCategory
|
||||
type CardCategory struct {
|
||||
Specialization SpecializationCode `json:"specialization"`
|
||||
Grade GradeCode `json:"grade"`
|
||||
// Coarse strength of the authoritative confirmation.
|
||||
Strength CardCategoryStrength `json:"strength"`
|
||||
Basis EvidenceBasis `json:"basis"`
|
||||
}
|
||||
|
||||
// GetSpecialization returns the value of Specialization.
|
||||
@@ -7054,6 +7070,11 @@ func (s *CardCategory) GetStrength() CardCategoryStrength {
|
||||
return s.Strength
|
||||
}
|
||||
|
||||
// GetBasis returns the value of Basis.
|
||||
func (s *CardCategory) GetBasis() EvidenceBasis {
|
||||
return s.Basis
|
||||
}
|
||||
|
||||
// SetSpecialization sets the value of Specialization.
|
||||
func (s *CardCategory) SetSpecialization(val SpecializationCode) {
|
||||
s.Specialization = val
|
||||
@@ -7069,6 +7090,11 @@ func (s *CardCategory) SetStrength(val CardCategoryStrength) {
|
||||
s.Strength = val
|
||||
}
|
||||
|
||||
// SetBasis sets the value of Basis.
|
||||
func (s *CardCategory) SetBasis(val EvidenceBasis) {
|
||||
s.Basis = val
|
||||
}
|
||||
|
||||
// Coarse strength of the authoritative confirmation.
|
||||
type CardCategoryStrength string
|
||||
|
||||
@@ -12918,10 +12944,13 @@ func (s *MatchAppliedFilters) SetConditions(val NilMatchAppliedConditions) {
|
||||
}
|
||||
|
||||
// A confirmed category. Its specialization must equal the enclosing match entry's specialization.
|
||||
// `basis` says what the grade rests on; `synthetic_demo` marks a demonstration category, which an
|
||||
// organization must read as one and never as a standard confirmation.
|
||||
// Ref: #/components/schemas/MatchCategory
|
||||
type MatchCategory struct {
|
||||
Specialization SpecializationCode `json:"specialization"`
|
||||
Grade GradeCode `json:"grade"`
|
||||
Basis EvidenceBasis `json:"basis"`
|
||||
}
|
||||
|
||||
// GetSpecialization returns the value of Specialization.
|
||||
@@ -12934,6 +12963,11 @@ func (s *MatchCategory) GetGrade() GradeCode {
|
||||
return s.Grade
|
||||
}
|
||||
|
||||
// GetBasis returns the value of Basis.
|
||||
func (s *MatchCategory) GetBasis() EvidenceBasis {
|
||||
return s.Basis
|
||||
}
|
||||
|
||||
// SetSpecialization sets the value of Specialization.
|
||||
func (s *MatchCategory) SetSpecialization(val SpecializationCode) {
|
||||
s.Specialization = val
|
||||
@@ -12944,6 +12978,11 @@ func (s *MatchCategory) SetGrade(val GradeCode) {
|
||||
s.Grade = val
|
||||
}
|
||||
|
||||
// SetBasis sets the value of Basis.
|
||||
func (s *MatchCategory) SetBasis(val EvidenceBasis) {
|
||||
s.Basis = val
|
||||
}
|
||||
|
||||
// Confirmation state for this specialization only. A result for one specialization never changes the
|
||||
// state of another specialization.
|
||||
// Ref: #/components/schemas/MatchConfirmationStatus
|
||||
@@ -18060,6 +18099,51 @@ func (o NilEmailAddress) Or(d EmailAddress) EmailAddress {
|
||||
return d
|
||||
}
|
||||
|
||||
// NewNilEvidenceBasis returns new NilEvidenceBasis with value set to v.
|
||||
func NewNilEvidenceBasis(v EvidenceBasis) NilEvidenceBasis {
|
||||
return NilEvidenceBasis{
|
||||
Value: v,
|
||||
}
|
||||
}
|
||||
|
||||
// NilEvidenceBasis is nullable EvidenceBasis.
|
||||
type NilEvidenceBasis struct {
|
||||
Value EvidenceBasis
|
||||
Null bool
|
||||
}
|
||||
|
||||
// SetTo sets value to v.
|
||||
func (o *NilEvidenceBasis) SetTo(v EvidenceBasis) {
|
||||
o.Null = false
|
||||
o.Value = v
|
||||
}
|
||||
|
||||
// IsNull returns true if value is Null.
|
||||
func (o NilEvidenceBasis) IsNull() bool { return o.Null }
|
||||
|
||||
// SetToNull sets value to null.
|
||||
func (o *NilEvidenceBasis) SetToNull() {
|
||||
o.Null = true
|
||||
var v EvidenceBasis
|
||||
o.Value = v
|
||||
}
|
||||
|
||||
// Get returns value and boolean that denotes whether value was set.
|
||||
func (o NilEvidenceBasis) Get() (v EvidenceBasis, ok bool) {
|
||||
if o.Null {
|
||||
return v, false
|
||||
}
|
||||
return o.Value, true
|
||||
}
|
||||
|
||||
// Or returns value if set, or given parameter if does not.
|
||||
func (o NilEvidenceBasis) Or(d EvidenceBasis) EvidenceBasis {
|
||||
if v, ok := o.Get(); ok {
|
||||
return v
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
// NewNilFloat64 returns new NilFloat64 with value set to v.
|
||||
func NewNilFloat64(v float64) NilFloat64 {
|
||||
return NilFloat64{
|
||||
@@ -26050,11 +26134,13 @@ type ProfileClaimTrustLevel int32
|
||||
// read-only and derived by the server from the assessment results of the candidate; no request carries
|
||||
// it and the profile storage holds no such column, so neither a form nor an import can write a
|
||||
// confirmed grade. It is separate from the claims of the profile and from the self-assessed grades in
|
||||
// `roles`.
|
||||
// `roles`. `basis` says what the grade rests on; `synthetic_demo` marks a demonstration category that
|
||||
// is not a validated measurement.
|
||||
// Ref: #/components/schemas/ProfileConfirmedCategory
|
||||
type ProfileConfirmedCategory struct {
|
||||
Specialization SpecializationCode `json:"specialization"`
|
||||
Grade GradeCode `json:"grade"`
|
||||
Basis EvidenceBasis `json:"basis"`
|
||||
ConfirmedAt Timestamp `json:"confirmed_at"`
|
||||
// Assessment attempt whose result confirmed the grade. The attempt belongs to the candidate.
|
||||
AttemptID uuid.UUID `json:"attempt_id"`
|
||||
@@ -26070,6 +26156,11 @@ func (s *ProfileConfirmedCategory) GetGrade() GradeCode {
|
||||
return s.Grade
|
||||
}
|
||||
|
||||
// GetBasis returns the value of Basis.
|
||||
func (s *ProfileConfirmedCategory) GetBasis() EvidenceBasis {
|
||||
return s.Basis
|
||||
}
|
||||
|
||||
// GetConfirmedAt returns the value of ConfirmedAt.
|
||||
func (s *ProfileConfirmedCategory) GetConfirmedAt() Timestamp {
|
||||
return s.ConfirmedAt
|
||||
@@ -26090,6 +26181,11 @@ func (s *ProfileConfirmedCategory) SetGrade(val GradeCode) {
|
||||
s.Grade = val
|
||||
}
|
||||
|
||||
// SetBasis sets the value of Basis.
|
||||
func (s *ProfileConfirmedCategory) SetBasis(val EvidenceBasis) {
|
||||
s.Basis = val
|
||||
}
|
||||
|
||||
// SetConfirmedAt sets the value of ConfirmedAt.
|
||||
func (s *ProfileConfirmedCategory) SetConfirmedAt(val Timestamp) {
|
||||
s.ConfirmedAt = val
|
||||
|
||||
@@ -4477,6 +4477,24 @@ func (s *AssessmentSpecializationAvailability) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.ConfirmedBasis.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := value.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "confirmed_basis",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if s.Grades == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
@@ -6388,6 +6406,17 @@ func (s *CardCategory) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Basis.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "basis",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
@@ -12044,6 +12073,17 @@ func (s *MatchCategory) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Basis.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "basis",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
@@ -19717,6 +19757,17 @@ func (s *ProfileConfirmedCategory) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Basis.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "basis",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
|
||||
@@ -49,11 +49,19 @@ func assessmentAvailabilityResponse(
|
||||
Grades: make([]api.AssessmentGradeAvailability, 0, len(item.Grades)),
|
||||
}
|
||||
specialization.ConfirmedGrade.SetToNull()
|
||||
specialization.ConfirmedBasis.SetToNull()
|
||||
if (item.ConfirmedGrade == nil) != (item.ConfirmedBasis == nil) {
|
||||
return api.AssessmentAvailability{}, errors.New("assessment availability pairs a confirmed grade with its basis inconsistently")
|
||||
}
|
||||
if item.ConfirmedGrade != nil {
|
||||
if !item.ConfirmedGrade.IsKnown() {
|
||||
return api.AssessmentAvailability{}, errors.New("assessment availability has an unknown confirmed grade")
|
||||
}
|
||||
if !item.ConfirmedBasis.IsKnown() {
|
||||
return api.AssessmentAvailability{}, errors.New("assessment availability has an unknown confirmed basis")
|
||||
}
|
||||
specialization.ConfirmedGrade.SetTo(api.GradeCode(*item.ConfirmedGrade))
|
||||
specialization.ConfirmedBasis.SetTo(api.EvidenceBasis(*item.ConfirmedBasis))
|
||||
}
|
||||
specialization.ActiveAttemptID.SetToNull()
|
||||
if item.ActiveAttemptID != nil {
|
||||
|
||||
@@ -97,3 +97,46 @@ func TestGetMyAssessmentAvailabilityMapsAuthAndUnavailableMode(t *testing.T) {
|
||||
}
|
||||
|
||||
func noPrincipalContext() context.Context { return context.Background() }
|
||||
|
||||
// A confirmed grade is never returned without the basis that says whether it
|
||||
// is a demonstration, and a basis never arrives without its grade.
|
||||
func TestAssessmentAvailabilityResponseCarriesTheBasisOfTheConfirmedGrade(t *testing.T) {
|
||||
basis := domain.AssessmentCategorySourceSyntheticDemo
|
||||
grade := domain.GradeJunior
|
||||
confirmed, err := assessmentAvailabilityResponse(assessmentusecase.AssessmentAvailability{
|
||||
Specializations: []assessmentusecase.SpecializationAvailability{{
|
||||
Specialization: domain.SpecializationBackend, ConfirmedGrade: &grade, ConfirmedBasis: &basis,
|
||||
}},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("assessmentAvailabilityResponse(confirmed) error = %v", err)
|
||||
}
|
||||
item := confirmed.Specializations[0]
|
||||
if grade, found := item.ConfirmedGrade.Get(); !found || grade != api.GradeCodeJunior {
|
||||
t.Fatalf("confirmed_grade = %+v, want junior", item.ConfirmedGrade)
|
||||
}
|
||||
if got, found := item.ConfirmedBasis.Get(); !found || got != api.EvidenceBasisSyntheticDemo {
|
||||
t.Fatalf("confirmed_basis = %+v, want synthetic_demo", item.ConfirmedBasis)
|
||||
}
|
||||
|
||||
unconfirmed, err := assessmentAvailabilityResponse(assessmentusecase.AssessmentAvailability{
|
||||
Specializations: []assessmentusecase.SpecializationAvailability{{Specialization: domain.SpecializationBackend}},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("assessmentAvailabilityResponse(unconfirmed) error = %v", err)
|
||||
}
|
||||
if !unconfirmed.Specializations[0].ConfirmedGrade.IsNull() || !unconfirmed.Specializations[0].ConfirmedBasis.IsNull() {
|
||||
t.Fatalf("unconfirmed specialization = %+v, want null grade and basis", unconfirmed.Specializations[0])
|
||||
}
|
||||
|
||||
for _, orphan := range []assessmentusecase.SpecializationAvailability{
|
||||
{Specialization: domain.SpecializationBackend, ConfirmedGrade: &grade},
|
||||
{Specialization: domain.SpecializationBackend, ConfirmedBasis: &basis},
|
||||
} {
|
||||
if _, err := assessmentAvailabilityResponse(assessmentusecase.AssessmentAvailability{
|
||||
Specializations: []assessmentusecase.SpecializationAvailability{orphan},
|
||||
}); err == nil {
|
||||
t.Fatalf("assessmentAvailabilityResponse(%+v) error = nil, want an inconsistent pair to fail", orphan)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,6 +225,7 @@ func matchConfirmedCandidate(entry matching.Entry) api.MatchConfirmedCandidate {
|
||||
if entry.Category != nil {
|
||||
candidate.Category = api.MatchCategory{
|
||||
Specialization: api.SpecializationCode(entry.Category.Specialization), Grade: api.GradeCode(entry.Category.Grade),
|
||||
Basis: api.EvidenceBasis(entry.Category.Basis),
|
||||
}
|
||||
candidate.Strength = api.MatchStrength(entry.Category.Strength)
|
||||
}
|
||||
|
||||
@@ -128,7 +128,10 @@ func TestSearchOrganizationMatchesMapsAConfirmedEntryWithANullPercentile(t *test
|
||||
handle := "cv1_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
stub := &matchOperationsStub{result: matching.Result{Main: []matching.Entry{{
|
||||
CandidateHandle: handle, Specialization: domain.SpecializationBackend,
|
||||
Category: &domain.CandidateViewCategory{Specialization: domain.SpecializationBackend, Grade: domain.GradeMiddle, Strength: domain.CandidateViewStrengthStrong},
|
||||
Category: &domain.CandidateViewCategory{
|
||||
Specialization: domain.SpecializationBackend, Grade: domain.GradeMiddle, Strength: domain.CandidateViewStrengthStrong,
|
||||
Basis: domain.AssessmentCategorySourceSyntheticDemo,
|
||||
},
|
||||
Components: matching.Components{
|
||||
Fit: 0.5, Coverage: 0.5, Domain: 0.5, Semantics: 0.5, Freshness: 0.5, Responsiveness: 0.5, RankScore: 0.45125,
|
||||
},
|
||||
@@ -147,7 +150,8 @@ func TestSearchOrganizationMatchesMapsAConfirmedEntryWithANullPercentile(t *test
|
||||
t.Fatalf("encode response: %v", err)
|
||||
}
|
||||
for _, want := range []string{
|
||||
`"confirmation_status":"confirmed"`, `"declared_grade":null`, `"category":{"specialization":"backend","grade":"middle"}`, `"strength":"strong"`,
|
||||
`"confirmation_status":"confirmed"`, `"declared_grade":null`,
|
||||
`"category":{"specialization":"backend","grade":"middle","basis":"synthetic_demo"}`, `"strength":"strong"`,
|
||||
`"percentile":null`, `"competition":0`, `"rank_score":0.45125`,
|
||||
} {
|
||||
if !strings.Contains(string(encoded), want) {
|
||||
|
||||
@@ -535,7 +535,7 @@ func anonymousCardResponse(view domain.AnonymousCandidateViewDTO) api.AnonymousC
|
||||
for _, category := range view.Categories {
|
||||
content.Categories = append(content.Categories, api.CardCategory{
|
||||
Specialization: api.SpecializationCode(category.Specialization), Grade: api.GradeCode(category.Grade),
|
||||
Strength: api.CardCategoryStrength(category.Strength),
|
||||
Strength: api.CardCategoryStrength(category.Strength), Basis: api.EvidenceBasis(category.Basis),
|
||||
})
|
||||
}
|
||||
for _, skill := range view.Skills {
|
||||
|
||||
@@ -23,6 +23,7 @@ func TestPrivacyGetOrganizationCandidateCardMapsClosedProjection(t *testing.T) {
|
||||
Pseudonym: "cv1_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
Categories: []domain.CandidateViewCategory{{
|
||||
Specialization: domain.SpecializationBackend, Grade: domain.GradeJunior, Strength: domain.CandidateViewStrengthStrong,
|
||||
Basis: domain.AssessmentCategorySourceSyntheticDemo,
|
||||
}},
|
||||
Skills: []domain.CandidateViewSkillCode{"go"},
|
||||
SelfAssessment: []domain.CandidateViewSelfAssessment{{
|
||||
@@ -45,6 +46,7 @@ func TestPrivacyGetOrganizationCandidateCardMapsClosedProjection(t *testing.T) {
|
||||
}
|
||||
if body.CacheControl != api.CacheControlNoStoreNoStore || body.Response.Pseudonym != view.Pseudonym ||
|
||||
len(body.Response.Categories) != 1 || body.Response.Categories[0].Strength != api.CardCategoryStrengthStrong ||
|
||||
body.Response.Categories[0].Basis != api.EvidenceBasisSyntheticDemo ||
|
||||
len(body.Response.Stack) != 1 || body.Response.Stack[0] != "go" ||
|
||||
len(body.Response.SelfAssessment) != 1 || body.Response.SelfAssessment[0].ConfirmationStatus != api.CardSelfAssessmentConfirmationStatusUnconfirmed {
|
||||
t.Fatalf("anonymous content mapping = %+v", body)
|
||||
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
// ProfileOperations reads and version-saves the authenticated candidate's
|
||||
// private manual profile.
|
||||
type ProfileOperations interface {
|
||||
GetMyProfile(ctx context.Context, userID uuid.UUID) (domain.CandidateProfile, error)
|
||||
SaveMyProfile(ctx context.Context, userID uuid.UUID, expectedVersion int64, input domain.CandidateProfileInput) (domain.CandidateProfile, error)
|
||||
GetMyProfile(ctx context.Context, userID uuid.UUID) (profile.View, error)
|
||||
SaveMyProfile(ctx context.Context, userID uuid.UUID, expectedVersion int64, input domain.CandidateProfileInput) (profile.View, error)
|
||||
}
|
||||
|
||||
// ProfileHandler serves the candidate's own profile operations.
|
||||
@@ -51,13 +51,13 @@ func (handler *ProfileHandler) GetMyProfile(ctx context.Context) (api.GetMyProfi
|
||||
if !ok {
|
||||
return (*api.GetMyProfileUnauthorized)(&problem.New(ctx, api.ProblemCodeUnauthenticated).Response), nil
|
||||
}
|
||||
profile, err := handler.operations.GetMyProfile(ctx, principal.UserID)
|
||||
view, err := handler.operations.GetMyProfile(ctx, principal.UserID)
|
||||
if err != nil {
|
||||
return profileReadFailure(ctx, err)
|
||||
}
|
||||
return &api.CandidateProfileHeaders{
|
||||
CacheControl: api.CacheControlNoStoreNoStore,
|
||||
Response: candidateProfileResponse(profile),
|
||||
Response: candidateProfileResponse(view),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ func (handler *ProfileHandler) SaveMyProfile(ctx context.Context, request *api.C
|
||||
if request == nil {
|
||||
return (*api.SaveMyProfileBadRequest)(&problem.InvalidField(ctx, api.ProblemFieldLocationBody, "").Response), nil
|
||||
}
|
||||
profile, err := handler.operations.SaveMyProfile(ctx, principal.UserID, int64(request.ExpectedVersion), candidateProfileInput(request))
|
||||
view, err := handler.operations.SaveMyProfile(ctx, principal.UserID, int64(request.ExpectedVersion), candidateProfileInput(request))
|
||||
if err != nil {
|
||||
return profileSaveFailure(ctx, err)
|
||||
}
|
||||
return &api.CandidateProfileHeaders{
|
||||
CacheControl: api.CacheControlNoStoreNoStore,
|
||||
Response: candidateProfileResponse(profile),
|
||||
Response: candidateProfileResponse(view),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -194,16 +194,16 @@ func profileYearMonth(value api.NilProfileYearMonth) string {
|
||||
return string(month)
|
||||
}
|
||||
|
||||
func candidateProfileResponse(profile domain.CandidateProfile) api.CandidateProfile {
|
||||
content := profile.Content()
|
||||
func candidateProfileResponse(view profile.View) api.CandidateProfile {
|
||||
saved := view.Profile
|
||||
content := saved.Content()
|
||||
response := api.CandidateProfile{
|
||||
Version: api.ProfileVersion(profile.Version()),
|
||||
ExperienceOverlaps: make([]api.ProfileExperienceOverlap, 0),
|
||||
Stack: make([]api.ProfileStackItem, 0),
|
||||
Roles: make([]api.ProfileRoleItem, 0),
|
||||
Experience: make([]api.ProfileExperienceItem, 0),
|
||||
SoftSkills: make([]api.ProfileSoftSkillItem, 0),
|
||||
ConfirmedCategories: make([]api.ProfileConfirmedCategory, 0),
|
||||
Version: api.ProfileVersion(saved.Version()),
|
||||
ExperienceOverlaps: make([]api.ProfileExperienceOverlap, 0),
|
||||
Stack: make([]api.ProfileStackItem, 0),
|
||||
Roles: make([]api.ProfileRoleItem, 0),
|
||||
Experience: make([]api.ProfileExperienceItem, 0),
|
||||
SoftSkills: make([]api.ProfileSoftSkillItem, 0),
|
||||
}
|
||||
if name, ok := content.FullName(); ok {
|
||||
response.FullName = profileFullNameClaim(name)
|
||||
@@ -279,15 +279,39 @@ func candidateProfileResponse(profile domain.CandidateProfile) api.CandidateProf
|
||||
}
|
||||
response.Terms = candidateProfileTerms(content)
|
||||
updatedAt := api.NilTimestamp{}
|
||||
if profile.UpdatedAt().IsZero() {
|
||||
if saved.UpdatedAt().IsZero() {
|
||||
updatedAt.SetToNull()
|
||||
} else {
|
||||
updatedAt.SetTo(api.Timestamp(profile.UpdatedAt()))
|
||||
updatedAt.SetTo(api.Timestamp(saved.UpdatedAt()))
|
||||
}
|
||||
response.UpdatedAt = updatedAt
|
||||
response.ConfirmedCategories = confirmedCategoriesResponse(view.ConfirmedCategories)
|
||||
return response
|
||||
}
|
||||
|
||||
// confirmedCategoriesResponse maps the categories in their stored order. The
|
||||
// result is never nil, so a profile without categories encodes as an empty list.
|
||||
func confirmedCategoriesResponse(categories []domain.CandidateAssessmentCategory) []api.ProfileConfirmedCategory {
|
||||
response := make([]api.ProfileConfirmedCategory, 0, len(categories))
|
||||
for _, category := range categories {
|
||||
response = append(response, confirmedCategoryResponse(category))
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
// confirmedCategoryResponse maps a stored category, including its basis, so a
|
||||
// demonstration grade is never returned as if an assessment had measured it.
|
||||
func confirmedCategoryResponse(category domain.CandidateAssessmentCategory) api.ProfileConfirmedCategory {
|
||||
snapshot := category.Snapshot()
|
||||
return api.ProfileConfirmedCategory{
|
||||
Specialization: api.SpecializationCode(snapshot.Specialization),
|
||||
Grade: api.GradeCode(snapshot.Grade),
|
||||
Basis: api.EvidenceBasis(snapshot.Source),
|
||||
ConfirmedAt: api.Timestamp(snapshot.AssignedAt),
|
||||
AttemptID: snapshot.SourceAttemptID.UUID(),
|
||||
}
|
||||
}
|
||||
|
||||
func candidateProfileTerms(content domain.CandidateProfileContent) api.ProfileTerms {
|
||||
terms := api.ProfileTerms{}
|
||||
if location, ok := content.Location(); ok {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"lincodex/backend/internal/adapter/primary/http/api"
|
||||
"lincodex/backend/internal/domain"
|
||||
"lincodex/backend/internal/usecase/profile"
|
||||
)
|
||||
|
||||
func TestCandidateProfileResponseCarriesConfirmedCategoriesWithTheirBasis(t *testing.T) {
|
||||
userID := uuid.New()
|
||||
saved, err := domain.EmptyCandidateProfile(userID)
|
||||
if err != nil {
|
||||
t.Fatalf("EmptyCandidateProfile() error = %v", err)
|
||||
}
|
||||
assignedAt := time.Date(2026, time.October, 8, 10, 30, 0, 0, time.UTC)
|
||||
attemptID := uuid.New()
|
||||
category, err := domain.RestoreCandidateAssessmentCategory(domain.CandidateAssessmentCategorySnapshot{
|
||||
CandidateID: userID, Specialization: domain.SpecializationBackend, Grade: domain.GradeJunior,
|
||||
SourceAttemptID: domain.AssessmentAttemptID(attemptID), SourceReviewID: uuid.New(),
|
||||
ProductPolicyVersionID: domain.PolicyVersionID(uuid.New()), ProductPolicyVersion: 1,
|
||||
OpeningID: uuid.New(), OpeningManifestHash: [32]byte{1},
|
||||
Source: domain.AssessmentCategorySourceSyntheticDemo, CalibrationStatus: domain.AssessmentCategoryCalibrationUncalibrated,
|
||||
AssignedAt: assignedAt,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("RestoreCandidateAssessmentCategory() error = %v", err)
|
||||
}
|
||||
|
||||
response := candidateProfileResponse(profile.View{Profile: saved, ConfirmedCategories: []domain.CandidateAssessmentCategory{category}})
|
||||
if len(response.ConfirmedCategories) != 1 {
|
||||
t.Fatalf("confirmed_categories = %+v, want one category", response.ConfirmedCategories)
|
||||
}
|
||||
got := response.ConfirmedCategories[0]
|
||||
if got.Specialization != api.SpecializationCodeBackend || got.Grade != api.GradeCodeJunior ||
|
||||
got.Basis != api.EvidenceBasisSyntheticDemo || got.AttemptID != attemptID || time.Time(got.ConfirmedAt) != assignedAt {
|
||||
t.Fatalf("confirmed category = %+v, want backend junior from attempt %s with basis synthetic_demo", got, attemptID)
|
||||
}
|
||||
|
||||
empty := candidateProfileResponse(profile.View{Profile: saved})
|
||||
if empty.ConfirmedCategories == nil || len(empty.ConfirmedCategories) != 0 {
|
||||
t.Fatalf("confirmed_categories of an empty view = %#v, want an empty list", empty.ConfirmedCategories)
|
||||
}
|
||||
}
|
||||
@@ -339,6 +339,29 @@ func (repository assessmentAttemptRepository) GetCandidateCategory(
|
||||
return category, true, nil
|
||||
}
|
||||
|
||||
func (repository assessmentAttemptRepository) ListCandidateCategories(
|
||||
ctx context.Context,
|
||||
candidateID uuid.UUID,
|
||||
) ([]domain.CandidateAssessmentCategory, error) {
|
||||
const location = "assessmentAttemptRepository.ListCandidateCategories"
|
||||
if candidateID == uuid.Nil {
|
||||
return nil, fmt.Errorf("%s - candidate scope is invalid: %w", location, domain.ErrInvalidAssessmentCategory)
|
||||
}
|
||||
rows, err := repository.queries.ListCandidateAssessmentCategories(ctx, pgUUID(candidateID))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s - select current categories: %w", location, mapAssessmentAttemptError(err))
|
||||
}
|
||||
categories := make([]domain.CandidateAssessmentCategory, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
category, err := restoreCandidateAssessmentCategory(row)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s - stored category is invalid: %w", location, err)
|
||||
}
|
||||
categories = append(categories, category)
|
||||
}
|
||||
return categories, nil
|
||||
}
|
||||
|
||||
func restoreCandidateAssessmentCategory(row sqlc.CandidateAssessmentCategory) (domain.CandidateAssessmentCategory, error) {
|
||||
manifestHash, err := assessmentManifestHash(row.OpeningManifestSha256)
|
||||
if err != nil || !row.CandidateID.Valid || !row.SourceAttemptID.Valid || !row.SourceReviewID.Valid ||
|
||||
|
||||
@@ -154,16 +154,18 @@ func newPrivacyCohortCandidate(
|
||||
const privacyCohortCategoryStrength = domain.CandidateViewStrengthStandard
|
||||
|
||||
// privacyCohortConfirmedCategories reads the current categories selected by
|
||||
// the cohort query: only a specialization and a grade of each, never the
|
||||
// attempt, score, policy, or review that produced it.
|
||||
// the cohort query: a specialization, a grade, and the basis of each, never the
|
||||
// attempt, score, policy, or review that produced it. A category without a
|
||||
// known basis is rejected rather than shown as a real confirmation.
|
||||
func privacyCohortConfirmedCategories(value any) ([]domain.CandidateViewConfirmedCategoryInput, error) {
|
||||
encoded, err := privacyCohortEncodedJSONBytes(value)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid confirmed categories: %w", domain.ErrInvalidCandidateViewSource)
|
||||
}
|
||||
var stored []struct {
|
||||
Specialization domain.SpecializationCode `json:"specialization"`
|
||||
Grade domain.GradeCode `json:"grade"`
|
||||
Specialization domain.SpecializationCode `json:"specialization"`
|
||||
Grade domain.GradeCode `json:"grade"`
|
||||
Source domain.AssessmentCategorySource `json:"source"`
|
||||
}
|
||||
decoder := json.NewDecoder(bytes.NewReader(encoded))
|
||||
decoder.DisallowUnknownFields()
|
||||
@@ -172,8 +174,12 @@ func privacyCohortConfirmedCategories(value any) ([]domain.CandidateViewConfirme
|
||||
}
|
||||
categories := make([]domain.CandidateViewConfirmedCategoryInput, 0, len(stored))
|
||||
for _, category := range stored {
|
||||
if !category.Source.IsKnown() {
|
||||
return nil, fmt.Errorf("confirmed category has an unknown basis: %w", domain.ErrInvalidCandidateViewSource)
|
||||
}
|
||||
categories = append(categories, domain.CandidateViewConfirmedCategoryInput{
|
||||
Specialization: category.Specialization, Grade: category.Grade, Strength: privacyCohortCategoryStrength,
|
||||
Specialization: category.Specialization, Grade: category.Grade,
|
||||
Strength: privacyCohortCategoryStrength, Basis: category.Source,
|
||||
})
|
||||
}
|
||||
return categories, nil
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"lincodex/backend/internal/domain"
|
||||
)
|
||||
|
||||
func TestPrivacyCohortConfirmedCategoriesCarryTheStoredBasis(t *testing.T) {
|
||||
categories, err := privacyCohortConfirmedCategories(`[{"specialization":"backend","grade":"junior","source":"synthetic_demo"}]`)
|
||||
if err != nil {
|
||||
t.Fatalf("privacyCohortConfirmedCategories() error = %v", err)
|
||||
}
|
||||
if len(categories) != 1 || categories[0].Specialization != domain.SpecializationBackend ||
|
||||
categories[0].Grade != domain.GradeJunior || categories[0].Basis != domain.AssessmentCategorySourceSyntheticDemo {
|
||||
t.Fatalf("categories = %+v, want the backend junior category with its synthetic basis", categories)
|
||||
}
|
||||
}
|
||||
|
||||
// A category whose basis is missing or unknown must not reach a card as if it
|
||||
// were a real confirmation, so the projection fails instead of guessing.
|
||||
func TestPrivacyCohortConfirmedCategoriesRejectAnUnknownBasis(t *testing.T) {
|
||||
for name, value := range map[string]string{
|
||||
"missing basis": `[{"specialization":"backend","grade":"junior"}]`,
|
||||
"unknown basis": `[{"specialization":"backend","grade":"junior","source":"real"}]`,
|
||||
"unknown property": `[{"specialization":"backend","grade":"junior","source":"synthetic_demo","score":9}]`,
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
if _, err := privacyCohortConfirmedCategories(value); !errors.Is(err, domain.ErrInvalidCandidateViewSource) {
|
||||
t.Fatalf("privacyCohortConfirmedCategories() error = %v, want invalid candidate view source", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user