Skip to content

Commit

Permalink
🐛 Update assessed to include empty assessment check
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 committed Oct 18, 2023
1 parent f53137d commit 84ee345
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions assessment/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/konveyor/tackle2-hub/model"
)

//
// NewApplicationResolver creates a new ApplicationResolver from an application and other shared resolvers.
func NewApplicationResolver(app *model.Application, tags *TagResolver, membership *MembershipResolver, questionnaire *QuestionnaireResolver) (a *ApplicationResolver) {
a = &ApplicationResolver{
Expand All @@ -16,7 +15,6 @@ func NewApplicationResolver(app *model.Application, tags *TagResolver, membershi
return
}

//
// ApplicationResolver wraps an Application model
// with archetype and assessment resolution behavior.
type ApplicationResolver struct {
Expand All @@ -27,7 +25,6 @@ type ApplicationResolver struct {
questionnaireResolver *QuestionnaireResolver
}

//
// Archetypes returns the list of archetypes the application is a member of.
func (r *ApplicationResolver) Archetypes() (archetypes []model.Archetype, err error) {
if len(r.archetypes) > 0 {
Expand All @@ -39,7 +36,6 @@ func (r *ApplicationResolver) Archetypes() (archetypes []model.Archetype, err er
return
}

//
// ArchetypeTags returns the list of tags that the application should inherit from the archetypes it is a member of,
// including any tags that would be inherited due to answers given to the archetypes' assessments.
func (r *ApplicationResolver) ArchetypeTags() (tags []model.Tag, err error) {
Expand Down Expand Up @@ -73,7 +69,6 @@ func (r *ApplicationResolver) ArchetypeTags() (tags []model.Tag, err error) {
return
}

//
// AssessmentTags returns the list of tags that the application should inherit from the answers given
// to its assessments.
func (r *ApplicationResolver) AssessmentTags() (tags []model.Tag) {
Expand All @@ -90,7 +85,6 @@ func (r *ApplicationResolver) AssessmentTags() (tags []model.Tag) {
return
}

//
// Assessed returns whether the application has been fully assessed.
func (r *ApplicationResolver) Assessed() (assessed bool, err error) {
// if the application has any of its own assessments, only consider them for
Expand All @@ -99,16 +93,19 @@ func (r *ApplicationResolver) Assessed() (assessed bool, err error) {
assessed = r.questionnaireResolver.Assessed(r.application.Assessments)
return
}
assessed = false

// otherwise the application is assessed if all of its archetypes are fully assessed.
archetypes, err := r.Archetypes()
if err != nil {
return
}
assessedCount := 0
for _, a := range archetypes {
if !r.questionnaireResolver.Assessed(a.Assessments) {
return
if r.questionnaireResolver.Assessed(a.Assessments) {
assessedCount++
}
}
assessed = true
assessed = assessedCount > 0 && assessedCount == len(archetypes)
return
}

0 comments on commit 84ee345

Please sign in to comment.