This commit is contained in:
Simon Martens
2025-02-18 01:09:26 +01:00
parent 7aac147686
commit b07ac82be9
2 changed files with 47 additions and 15 deletions

View File

@@ -34,6 +34,41 @@ func (p Piece) String() string {
return string(data)
}
func (p Piece) Categories() map[string]bool {
cats := make(map[string]bool)
for _, c := range p.CategoryRefs {
cats[c.Category] = true
}
for _, i := range p.IssueRefs {
cats[i.Category] = true
}
for _, i := range p.PlaceRefs {
cats[i.Category] = true
}
for _, i := range p.AgentRefs {
if i.Category == "" {
cats["autor"] = true
}
cats[i.Category] = true
}
for _, i := range p.WorkRefs {
if i.Category == "" {
cats["rezension"] = true
}
cats[i.Category] = true
}
for _, i := range p.PieceRefs {
cats[i.Category] = true
}
return cats
}
func (p Piece) Keys() []string {
if len(p.keys) > 0 {
return p.keys