probo/store/participant.go

33 lines
756 B
Go
Raw Normal View History

package store
import "git.andreafazzi.eu/andrea/probo/models"
2023-11-21 15:12:13 +01:00
type ParticipantStore struct {
*FilterStore[*models.Participant]
}
func NewParticipantStore() *ParticipantStore {
store := new(ParticipantStore)
store.FilterStore = NewFilterStore[*models.Participant]()
return store
}
func (s *ParticipantStore) FilterInGroup(group *models.Group, filter *models.ParticipantFilter) []*models.Participant {
participants := s.ReadAll()
filteredParticipants := s.Filter(participants, func(p *models.Participant) bool {
for pk, pv := range p.Attributes {
for fk, fv := range filter.Attributes {
if pk == fk && pv == fv {
return true
}
}
}
return false
})
group.Participants = filteredParticipants
return group.Participants
}