Fonts + Only Pointers in sync.Maps

This commit is contained in:
Simon Martens
2024-12-20 01:10:39 +01:00
parent 9012fdcb17
commit 3ef30ef7c7
17 changed files with 323 additions and 255 deletions

View File

@@ -8,6 +8,8 @@ import (
type AgentView struct {
Agents []xmlprovider.Agent
Works map[string][]xmlprovider.Work
Pieces map[string][]xmlprovider.Piece
}
func AgentsView(letterorid string, lib *xmlprovider.Library) *AgentView {
@@ -21,5 +23,36 @@ func AgentsView(letterorid string, lib *xmlprovider.Library) *AgentView {
return true
})
res.Works = make(map[string][]xmlprovider.Work)
res.Pieces = make(map[string][]xmlprovider.Piece)
lib.Works.Items.Range(func(key, value interface{}) bool {
w := value.(xmlprovider.Work)
for _, a := range res.Agents {
if strings.HasPrefix(a.ID, letterorid) {
_, ok := res.Works[a.ID]
if !ok {
res.Works[a.ID] = []xmlprovider.Work{}
}
res.Works[a.ID] = append(res.Works[a.ID], w)
}
}
return true
})
lib.Pieces.Items.Range(func(key, value interface{}) bool {
p := value.(xmlprovider.Piece)
for _, a := range res.Agents {
if strings.HasPrefix(a.ID, letterorid) {
_, ok := res.Pieces[a.ID]
if !ok {
res.Pieces[a.ID] = []xmlprovider.Piece{}
}
res.Pieces[a.ID] = append(res.Pieces[a.ID], p)
}
}
return true
})
return &res
}