refactor: add tag and relation methods to node to enforce integrity

This commit is contained in:
2026-03-29 23:16:44 +02:00
parent 4ebcb88628
commit dadd3d9e13
15 changed files with 313 additions and 179 deletions

View File

@@ -77,7 +77,8 @@ func PrintNodes(w io.Writer, svc service.NodeService, nodes []*models.Node, json
})
for _, n := range nodes {
ns_rel_node_ids := n.Relations[string(models.RelInNamespace)]
n_rels := n.Relations()
ns_rel_node_ids := n_rels[string(models.RelInNamespace)]
ns_rel_node_titles := make([]string, 0, len(ns_rel_node_ids))
for _, id := range ns_rel_node_ids {
ns_rel_node, err := svc.GetByID(id)
@@ -123,8 +124,9 @@ func PrintNode(w io.Writer, svc service.NodeService, n *models.Node, jsonOut boo
fmt.Fprintf(w, "\n tags: %s\n", cPrimary.Sprint(strings.Join(tags, " • ")))
}
for relType := range n.Relations {
rel_node_ids := n.Relations[string(relType)]
n_rels := n.Relations()
for relType := range n_rels {
rel_node_ids := n_rels[string(relType)]
if len(rel_node_ids) > 0 {
fmt.Fprintf(w, "\n %s\n", string(relType))
}