diff --git a/internal/post.go b/internal/post/post.go similarity index 99% rename from internal/post.go rename to internal/post/post.go index 5cb765d..dfb5e10 100644 --- a/internal/post.go +++ b/internal/post/post.go @@ -1,4 +1,4 @@ -package internal +package post import ( "context" diff --git a/internal/relationships.go b/internal/relation/relationships.go similarity index 99% rename from internal/relationships.go rename to internal/relation/relationships.go index 7e18bca..b0d6a26 100644 --- a/internal/relationships.go +++ b/internal/relation/relationships.go @@ -1,4 +1,4 @@ -package internal +package relation import ( "context" diff --git a/internal/source.go b/internal/source/source.go similarity index 99% rename from internal/source.go rename to internal/source/source.go index bb91fdf..fde7798 100644 --- a/internal/source.go +++ b/internal/source/source.go @@ -1,4 +1,4 @@ -package internal +package source import ( "context" diff --git a/internal/tag.go b/internal/tag/tag.go similarity index 99% rename from internal/tag.go rename to internal/tag/tag.go index 3e5a02d..4da0918 100644 --- a/internal/tag.go +++ b/internal/tag/tag.go @@ -1,4 +1,4 @@ -package internal +package tag import ( "context" diff --git a/internal/user.go b/internal/user/user.go similarity index 99% rename from internal/user.go rename to internal/user/user.go index d210e3a..ec66e61 100644 --- a/internal/user.go +++ b/internal/user/user.go @@ -1,4 +1,4 @@ -package internal +package user import ( "context" diff --git a/internal/logger.go b/internal/utils/logger.go similarity index 98% rename from internal/logger.go rename to internal/utils/logger.go index 446869d..373c76d 100644 --- a/internal/logger.go +++ b/internal/utils/logger.go @@ -1,4 +1,4 @@ -package internal +package utils import ( "fmt" diff --git a/pkg/graph/graph_impl.go b/pkg/graph/graph_impl.go index a01b58b..42fa30e 100644 --- a/pkg/graph/graph_impl.go +++ b/pkg/graph/graph_impl.go @@ -3,7 +3,7 @@ package graph import ( "context" - "git.dragse.it/anthrove/otter-space-sdk/internal" + "git.dragse.it/anthrove/otter-space-sdk/internal/utils" "github.com/neo4j/neo4j-go-driver/v5/neo4j" "github.com/neo4j/neo4j-go-driver/v5/neo4j/config" ) @@ -37,6 +37,6 @@ func (g *graphConnection) Connect(ctx context.Context, endpoint string, username func logger(graphDebug bool) func(config *config.Config) { return func(config *config.Config) { - config.Log = internal.NewGraphLogger(graphDebug) + config.Log = utils.NewGraphLogger(graphDebug) } } diff --git a/pkg/graph/post.go b/pkg/graph/post.go index c228ee3..5053858 100644 --- a/pkg/graph/post.go +++ b/pkg/graph/post.go @@ -27,6 +27,5 @@ type Post interface { CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*models.AnthrovePost, bool, error) // LinkPostWithSource establishes a link between a post and a source in the OtterSpace graph. - // It returns an error if the operation fails. LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error } diff --git a/pkg/graph/post_impl.go b/pkg/graph/post_impl.go index ff7e506..e6cc558 100644 --- a/pkg/graph/post_impl.go +++ b/pkg/graph/post_impl.go @@ -3,36 +3,37 @@ package graph import ( "context" - "git.dragse.it/anthrove/otter-space-sdk/internal" + "git.dragse.it/anthrove/otter-space-sdk/internal/post" + "git.dragse.it/anthrove/otter-space-sdk/internal/relation" "git.dragse.it/anthrove/otter-space-sdk/pkg/models" ) // CreatePost will always create a new node, it does not check if the node with the corresponding post_id and rating exists. func (g *graphConnection) CreatePost(ctx context.Context, anthrovePost *models.AnthrovePost) error { - return internal.CreateAnthrovePostNode(ctx, g.driver, anthrovePost) + return post.CreateAnthrovePostNode(ctx, g.driver, anthrovePost) } // DeletePost will always delete a node, it only needs the anthrovePost.PostID filled out. func (g *graphConnection) DeletePost(ctx context.Context, anthrovePost *models.AnthrovePost) error { - return internal.DeleteAnthrovePostNode(ctx, g.driver, anthrovePost) + return post.DeleteAnthrovePostNode(ctx, g.driver, anthrovePost) } // CheckPostNodeExistsBySourceID checks if a models.AnthrovePost exists by its sourcePostID. func (g *graphConnection) CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*models.AnthrovePost, bool, error) { - return internal.AnthroveNodeExistsBySourceID(ctx, g.driver, sourcePostID) + return post.AnthroveNodeExistsBySourceID(ctx, g.driver, sourcePostID) } // CheckPostNodeExistsByAnthroveID checks if a models.AnthrovePost exists by its models.AnthrovePostID. func (g *graphConnection) CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error) { - return internal.AnthroveNodeExistsByAnthroveID(ctx, g.driver, anthrovePost) + return post.AnthroveNodeExistsByAnthroveID(ctx, g.driver, anthrovePost) } // CheckPostNodeExistsBySourceURL checks if a models.AnthrovePost exists by its sourceUrl. func (g *graphConnection) CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*models.AnthrovePost, bool, error) { - return internal.AnthroveNodeExistsBySourceURL(ctx, g.driver, sourceUrl) + return post.AnthroveNodeExistsBySourceURL(ctx, g.driver, sourceUrl) } func (g *graphConnection) LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error { - return internal.EstablishAnthrovePostToSourceLink(ctx, g.driver, anthrovePostID, anthroveSourceDomain, anthrovePostRelationship) + return relation.EstablishAnthrovePostToSourceLink(ctx, g.driver, anthrovePostID, anthroveSourceDomain, anthrovePostRelationship) } diff --git a/pkg/graph/source_impl.go b/pkg/graph/source_impl.go index 4aaab61..fd96c0e 100644 --- a/pkg/graph/source_impl.go +++ b/pkg/graph/source_impl.go @@ -2,12 +2,14 @@ package graph import ( "context" - "git.dragse.it/anthrove/otter-space-sdk/internal" + + "git.dragse.it/anthrove/otter-space-sdk/internal/source" + "git.dragse.it/anthrove/otter-space-sdk/internal/user" "git.dragse.it/anthrove/otter-space-sdk/pkg/models" ) func (g *graphConnection) CreateSource(ctx context.Context, anthroveSource *models.AnthroveSource) error { - return internal.CreateSourceNode(ctx, g.driver, anthroveSource) + return source.CreateSourceNode(ctx, g.driver, anthroveSource) } func (g *graphConnection) DeleteSource(ctx context.Context, anthroveSource *models.AnthroveSource) error { @@ -16,17 +18,17 @@ func (g *graphConnection) DeleteSource(ctx context.Context, anthroveSource *mode } func (g *graphConnection) GetSourceByURL(ctx context.Context, sourceUrl string) (*models.AnthroveSource, error) { - return internal.GetSourceNodesByURL(ctx, g.driver, sourceUrl) + return source.GetSourceNodesByURL(ctx, g.driver, sourceUrl) } func (g *graphConnection) GetAllSources(ctx context.Context) ([]models.AnthroveSource, error) { - return internal.GetAllSourceNodes(ctx, g.driver) + return source.GetAllSourceNodes(ctx, g.driver) } func (g *graphConnection) GetSourceLinkForSpecifiedUser(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]models.AnthroveUserRelationship, error) { - return internal.GetSpecifiedUserSourceLink(ctx, g.driver, anthroveUserID, sourceDisplayName) + return user.GetSpecifiedUserSourceLink(ctx, g.driver, anthroveUserID, sourceDisplayName) } func (g *graphConnection) GetSourceLinkForUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error) { - return internal.GetUserSourceLink(ctx, g.driver, anthroveUserID) + return user.GetUserSourceLink(ctx, g.driver, anthroveUserID) } diff --git a/pkg/graph/tag_impl.go b/pkg/graph/tag_impl.go index 14a78d8..b0d2b35 100644 --- a/pkg/graph/tag_impl.go +++ b/pkg/graph/tag_impl.go @@ -2,7 +2,8 @@ package graph import ( "context" - "git.dragse.it/anthrove/otter-space-sdk/internal" + + "git.dragse.it/anthrove/otter-space-sdk/internal/tag" "git.dragse.it/anthrove/otter-space-sdk/pkg/models" ) @@ -17,9 +18,9 @@ func (g *graphConnection) DeleteTag() error { } func (g *graphConnection) AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.AnthroveTag) error { - return internal.CreateTagNodeWitRelation(ctx, g.driver, anthrovePostID, anthroveTag) + return tag.CreateTagNodeWitRelation(ctx, g.driver, anthrovePostID, anthroveTag) } func (g *graphConnection) GetAllTags(ctx context.Context) ([]models.TagsWithFrequency, error) { - return internal.GetTags(ctx, g.driver) + return tag.GetTags(ctx, g.driver) } diff --git a/pkg/graph/user_impl.go b/pkg/graph/user_impl.go index a383b73..fdc58b5 100644 --- a/pkg/graph/user_impl.go +++ b/pkg/graph/user_impl.go @@ -3,7 +3,9 @@ package graph import ( "context" "fmt" - "git.dragse.it/anthrove/otter-space-sdk/internal" + + "git.dragse.it/anthrove/otter-space-sdk/internal/relation" + "git.dragse.it/anthrove/otter-space-sdk/internal/user" "git.dragse.it/anthrove/otter-space-sdk/pkg/models" ) @@ -18,33 +20,33 @@ func (g *graphConnection) DeleteUser(ctx context.Context, anthroveUserID models. } func (g *graphConnection) CreateUserWithRelationToSource(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDomain string, userID string, username string) error { - return internal.CreateUserNodeWithSourceRelation(ctx, g.driver, anthroveUserID, sourceDomain, userID, username) + return user.CreateUserNodeWithSourceRelation(ctx, g.driver, anthroveUserID, sourceDomain, userID, username) } func (g *graphConnection) GetUserTagsTroughFavedPosts(ctx context.Context, anthroveUserID models.AnthroveUserID) ([]models.TagsWithFrequency, error) { - return internal.GetUserTagNodeWitRelationToFavedPosts(ctx, g.driver, anthroveUserID) + return user.GetUserTagNodeWitRelationToFavedPosts(ctx, g.driver, anthroveUserID) } func (g *graphConnection) GetUserFavoritePostsWithPagination(ctx context.Context, anthroveUserID models.AnthroveUserID, skip int, limit int) (*models.FavoriteList, error) { - return internal.GetUserFavoriteNodeWithPagination(ctx, g.driver, anthroveUserID, skip, limit) + return user.GetUserFavoriteNodeWithPagination(ctx, g.driver, anthroveUserID, skip, limit) } func (g *graphConnection) GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*models.AnthroveUser, error) { - return internal.GetAnthroveUser(ctx, g.driver, anthroveUserID) + return user.GetAnthroveUser(ctx, g.driver, anthroveUserID) } func (g *graphConnection) GetUserFavoriteCount(ctx context.Context, anthroveUserID models.AnthroveUserID) (int64, error) { - return internal.GetUserFavoritesCount(ctx, g.driver, anthroveUserID) + return user.GetUserFavoritesCount(ctx, g.driver, anthroveUserID) } func (g *graphConnection) CheckUserPostLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourcePostID string, sourceUrl string) (bool, error) { - return internal.CheckUserToPostLink(ctx, g.driver, anthroveUserID, sourcePostID, sourceUrl) + return relation.CheckUserToPostLink(ctx, g.driver, anthroveUserID, sourcePostID, sourceUrl) } func (g *graphConnection) LinkUserWithPost(ctx context.Context, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error { - return internal.EstablishUserToPostLink(ctx, g.driver, anthroveUser, anthrovePost) + return relation.EstablishUserToPostLink(ctx, g.driver, anthroveUser, anthrovePost) } func (g *graphConnection) GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error) { - return internal.GetAllAnthroveUserIDs(ctx, g.driver) + return user.GetAllAnthroveUserIDs(ctx, g.driver) }