-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_of_organization.go
49 lines (39 loc) · 1.16 KB
/
table_of_organization.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package pkg
import (
mapset "github.com/deckarep/golang-set/v2"
"github.com/pkg/errors"
)
type TableOfOrganization struct {
StaffGroups []StaffGroup
Flights []Flight
Unassigned MemberGroup
Inactive MemberGroup
InactiveCAPIDs mapset.Set[uint]
}
func (to *TableOfOrganization) PopulateMemberData(members map[uint]Member) (err error) {
assigned := mapset.NewSet[uint]()
var staffGroups []StaffGroup
for _, group := range to.StaffGroups {
err = group.PopulateMemberData(members, &assigned)
if err != nil {
// TODO: Instead of halting on error, continue to populate and return a slice of errors
err = errors.WithStack(err)
return err
}
staffGroups = append(staffGroups, group)
}
to.StaffGroups = staffGroups
var flights []Flight
for _, flight := range to.Flights {
err = flight.PopulateMemberData(members, &assigned)
if err != nil {
// TODO: Instead of halting on error, continue to populate and return a slice of errors
err = errors.WithStack(err)
return err
}
flights = append(flights, flight)
}
to.Flights = flights
to.Unassigned = NewUnassignedMemberGroup(members, assigned, to.InactiveCAPIDs)
return nil
}