Skip to content

Commit 313ed17

Browse files
committed
Fix opportunity on organization volunteers
1 parent 031e78b commit 313ed17

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

internal/opportunities/service.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,15 +1033,26 @@ func (s *service) GetOrganizationOpportunityVolunteers(ctx context.Context, orga
10331033
}
10341034

10351035
ids := []int64{}
1036+
opportunitiesMap := map[int64]models.Opportunity{}
10361037
for _, opportunity := range opportunities {
10371038
ids = append(ids, opportunity.ID)
1039+
opportunitiesMap[opportunity.ID] = opportunity
10381040
}
10391041

10401042
opportunityMemberships, err := s.opportunityMembershipRepository.FindByOpportunityIDs(ctx, ids)
10411043
if err != nil {
10421044
return nil, NewErrServerError()
10431045
}
10441046

1047+
for i := 0; i < len(opportunityMemberships); i++ {
1048+
opportunity, ok := opportunitiesMap[opportunityMemberships[i].OpportunityID]
1049+
if !ok {
1050+
continue
1051+
}
1052+
1053+
opportunityMemberships[i].Opportunity = opportunity
1054+
}
1055+
10451056
return opportunityMemberships, nil
10461057
}
10471058

0 commit comments

Comments
 (0)