Skip to content

Commit

Permalink
🐛 Preload assessment stakeholder relationships (konveyor#544)
Browse files Browse the repository at this point in the history
The assessment stakeholder relationships need to be preloaded so that
the `applications/id/assessments` and `archetypes/id/assessments`
subresources populate their association fields properly.

Signed-off-by: Sam Lucidi <slucidi@redhat.com>
  • Loading branch information
mansam authored and aufi committed Oct 30, 2023
1 parent b3d8435 commit a8edc31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,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)
db := h.preLoad(h.DB(ctx), clause.Associations, "Assessments.Stakeholders", "Assessments.Stakeholders")
db = db.Omit("Analyses")
result := db.First(m, id)
if result.Error != nil {
Expand Down
2 changes: 2 additions & 0 deletions assessment/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func (r *MembershipResolver) cacheArchetypes() (err error) {

list := []model.Archetype{}
db := r.db.Preload(clause.Associations)
db = db.Preload("Assessments.Stakeholders")
db = db.Preload("Assessments.StakeholderGroups")
result := db.Find(&list)
if result.Error != nil {
err = liberr.Wrap(err)
Expand Down

0 comments on commit a8edc31

Please sign in to comment.