Skip to content

Commit

Permalink
👻 Add questionnare required field to assessment (#588)
Browse files Browse the repository at this point in the history
This is needed to aid UI in computing status for an assessment given a
questionnaire is marked as not required. If an assessment exists for an
archived questionnaire on an app or archetype, the assessment status is
no longer valid & the assessment will need to be filtered from status
consideration.

https://issues.redhat.com/browse/MTA-1956

Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 authored Jan 15, 2024
1 parent 951cb48 commit 2552233
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ func (h ApplicationHandler) StakeholdersUpdate(ctx *gin.Context) {
func (h ApplicationHandler) AssessmentList(ctx *gin.Context) {
m := &model.Application{}
id := h.pk(ctx)
db := h.preLoad(h.DB(ctx), clause.Associations, "Assessments.Stakeholders", "Assessments.StakeholderGroups")
db := h.preLoad(h.DB(ctx), clause.Associations, "Assessments.Stakeholders", "Assessments.StakeholderGroups", "Assessments.Questionnaire")
db = db.Omit("Analyses")
result := db.First(m, id)
if result.Error != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/archetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (h ArchetypeHandler) Update(ctx *gin.Context) {
func (h ArchetypeHandler) AssessmentList(ctx *gin.Context) {
m := &model.Archetype{}
id := h.pk(ctx)
db := h.preLoad(h.DB(ctx), clause.Associations, "Assessments.Stakeholders", "Assessments.StakeholderGroups")
db := h.preLoad(h.DB(ctx), clause.Associations, "Assessments.Stakeholders", "Assessments.StakeholderGroups", "Assessments.Questionnaire")
result := db.First(m, id)
if result.Error != nil {
_ = ctx.Error(result.Error)
Expand Down
2 changes: 2 additions & 0 deletions api/assessment.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ type Assessment struct {
Status string `json:"status"`
Thresholds assessment.Thresholds `json:"thresholds"`
RiskMessages assessment.RiskMessages `json:"riskMessages" yaml:"riskMessages"`
Required bool `json:"required"`
}

//
Expand All @@ -187,6 +188,7 @@ func (r *Assessment) With(m *model.Assessment) {
}
a := assessment.Assessment{}
a.With(m)
r.Required = a.Questionnaire.Required
r.Risk = a.Risk()
r.Confidence = a.Confidence()
r.RiskMessages = a.RiskMessages
Expand Down

0 comments on commit 2552233

Please sign in to comment.