Skip to content

Commit

Permalink
rename cluster resource to node
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed May 13, 2024
1 parent 73ae275 commit 0eb9961
Show file tree
Hide file tree
Showing 84 changed files with 8,231 additions and 8,249 deletions.
30 changes: 15 additions & 15 deletions app/resources/datagraph/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
)

type (
ClusterID xid.ID
ClusterSlug string
NodeID xid.ID
NodeSlug string
)

func (i ClusterID) String() string { return xid.ID(i).String() }
func (i NodeID) String() string { return xid.ID(i).String() }

type Cluster struct {
ID ClusterID
type Node struct {
ID NodeID
CreatedAt time.Time
UpdatedAt time.Time

Expand All @@ -30,19 +30,19 @@ type Cluster struct {
Description string
Content opt.Optional[string]
Owner profile.Profile
Parent opt.Optional[*Cluster]
Parent opt.Optional[*Node]
Visibility post.Visibility
Properties any

Clusters []*Cluster
Nodes []*Node
}

func (*Cluster) GetResourceName() string { return "cluster" }
func (*Node) GetResourceName() string { return "node" }

func (c *Cluster) GetID() xid.ID { return xid.ID(c.ID) }
func (c *Cluster) GetKind() Kind { return KindCluster }
func (c *Cluster) GetName() string { return c.Name }
func (c *Cluster) GetSlug() string { return c.Slug }
func (c *Cluster) GetDesc() string { return c.Description }
func (c *Cluster) GetText() string { return c.Content.String() }
func (c *Cluster) GetProps() any { return nil }
func (c *Node) GetID() xid.ID { return xid.ID(c.ID) }
func (c *Node) GetKind() Kind { return KindNode }
func (c *Node) GetName() string { return c.Name }
func (c *Node) GetSlug() string { return c.Slug }
func (c *Node) GetDesc() string { return c.Description }
func (c *Node) GetText() string { return c.Content.String() }
func (c *Node) GetProps() any { return nil }
119 changes: 0 additions & 119 deletions app/resources/datagraph/cluster/cluster.go

This file was deleted.

25 changes: 0 additions & 25 deletions app/resources/datagraph/cluster_children/cluster_children.go

This file was deleted.

18 changes: 6 additions & 12 deletions app/resources/datagraph/datagraph_enum_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions app/resources/datagraph/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package datagraph
type kindEnum string

const (
kindThread kindEnum = "thread"
kindReply kindEnum = "reply"
kindCluster kindEnum = "cluster"
kindLink kindEnum = "link"
kindThread kindEnum = "thread"
kindReply kindEnum = "reply"
kindNode kindEnum = "node"
kindLink kindEnum = "link"
)
4 changes: 2 additions & 2 deletions app/resources/datagraph/link/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func WithPosts(ids ...xid.ID) Option {
}
}

func WithClusters(ids ...xid.ID) Option {
func WithNodes(ids ...xid.ID) Option {
return func(lm *ent.LinkMutation) {
lm.AddClusterIDs(ids...)
lm.AddNodeIDs(ids...)
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/resources/datagraph/link_graph/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (d *database) Get(ctx context.Context, slug string) (*WithRefs, error) {
pq.WithCategory()
pq.WithRoot()
}).
WithClusters()
WithNodes()

r, err := query.First(ctx)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions app/resources/datagraph/link_graph/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type WithRefs struct {
Assets []*asset.Asset
Threads []*thread.Thread
Replies []*reply.Reply
Clusters []*datagraph.Cluster
Nodes []*datagraph.Node
Related datagraph.NodeReferenceList
}

Expand All @@ -52,7 +52,7 @@ func Map(in *ent.Link) (*WithRefs, error) {
return nil, fault.Wrap(err)
}

clusterEdge, err := in.Edges.ClustersOrErr()
nodeEdge, err := in.Edges.NodesOrErr()
if err != nil {
return nil, fault.Wrap(err)
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func Map(in *ent.Link) (*WithRefs, error) {
return nil, fault.Wrap(err)
}

clusters, err := dt.MapErr(clusterEdge, datagraph.ClusterFromModel)
nodes, err := dt.MapErr(nodeEdge, datagraph.NodeFromModel)
if err != nil {
return nil, fault.Wrap(err)
}
Expand All @@ -99,6 +99,6 @@ func Map(in *ent.Link) (*WithRefs, error) {
Assets: dt.Map(in.Edges.Assets, asset.FromModel),
Threads: threads,
Replies: replies,
Clusters: clusters,
Nodes: nodes,
}, nil
}
10 changes: 5 additions & 5 deletions app/resources/datagraph/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/Southclaws/storyden/internal/ent"
)

func ClusterFromModel(c *ent.Cluster) (*Cluster, error) {
func NodeFromModel(c *ent.Node) (*Node, error) {
accEdge, err := c.Edges.OwnerOrErr()
if err != nil {
return nil, fault.Wrap(err)
Expand All @@ -22,7 +22,7 @@ func ClusterFromModel(c *ent.Cluster) (*Cluster, error) {
return nil, fault.Wrap(err)
}

clusters, err := dt.MapErr(c.Edges.Clusters, ClusterFromModel)
nodes, err := dt.MapErr(c.Edges.Nodes, NodeFromModel)
if err != nil {
return nil, fault.Wrap(err)
}
Expand All @@ -34,8 +34,8 @@ func ClusterFromModel(c *ent.Cluster) (*Cluster, error) {

assets := dt.Map(c.Edges.Assets, asset.FromModel)

return &Cluster{
ID: ClusterID(c.ID),
return &Node{
ID: NodeID(c.ID),
CreatedAt: c.CreatedAt,
UpdatedAt: c.UpdatedAt,
Name: c.Name,
Expand All @@ -45,7 +45,7 @@ func ClusterFromModel(c *ent.Cluster) (*Cluster, error) {
Description: c.Description,
Content: opt.NewPtr(c.Content),
Owner: *pro,
Clusters: clusters,
Nodes: nodes,
Visibility: visibility,
Properties: c.Properties,
}, nil
Expand Down

0 comments on commit 0eb9961

Please sign in to comment.