docs(post): added function documentation

Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
SoXX 2024-05-31 15:24:05 +02:00
parent fc73377d86
commit 1017eaf5b8
5 changed files with 13 additions and 10 deletions

View File

@ -1,4 +1,4 @@
package relation
package relations
import (
"context"
@ -9,7 +9,8 @@ import (
log "github.com/sirupsen/logrus"
)
func EstablishAnthrovePostToSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error {
// CreateAnthrovePostToSourceLink establishes a link between a models.AnthrovePost and a models.AnthroveSource
func CreateAnthrovePostToSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error {
query := `
MATCH (sourceNode:Source {domain: $source_url})
MATCH (postNode:AnthrovePost {post_id: $anthrove_post_id})

View File

@ -217,8 +217,8 @@ func GetAnthroveUser(ctx context.Context, driver neo4j.DriverWithContext, anthro
userRelationships := make([]models.AnthroveUserRelationship, 0)
query := `
MATCH (user:User{user_id: $anthrove_user_id})-[relation:HAS_ACCOUNT_AT]->(source:Source)
RETURN user as User, relation as Relation, source as Source;
MATCH (user:User{user_id: $anthrove_user_id})-[relations:HAS_ACCOUNT_AT]->(source:Source)
RETURN user as User, relations as Relation, source as Source;
`
params := map[string]any{
"anthrove_user_id": anthroveUserID,

View File

@ -4,7 +4,7 @@ import (
"context"
"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/internal/relations"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
)
@ -34,6 +34,7 @@ func (g *graphConnection) CheckPostNodeExistsBySourceURL(ctx context.Context, so
return post.AnthroveNodeExistsBySourceURL(ctx, g.driver, sourceUrl)
}
// LinkPostWithSource establishes a link between a models.AnthrovePost and a models.AnthroveSource
func (g *graphConnection) LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error {
return relation.EstablishAnthrovePostToSourceLink(ctx, g.driver, anthrovePostID, anthroveSourceDomain, anthrovePostRelationship)
return relations.CreateAnthrovePostToSourceLink(ctx, g.driver, anthrovePostID, anthroveSourceDomain, anthrovePostRelationship)
}

View File

@ -2,6 +2,7 @@ package graph
import (
"context"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
)
@ -27,7 +28,7 @@ type User interface {
// It returns the user and an error if the operation fails.
GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*models.AnthroveUser, error)
// GetUserFavoritePostsWithPagination gets all user favorites with relation and sources for the given user
// GetUserFavoritePostsWithPagination gets all user favorites with relations and sources for the given user
GetUserFavoritePostsWithPagination(ctx context.Context, anthroveUserID models.AnthroveUserID, skip int, limit int) (*models.FavoriteList, error)
// GetUserTagsTroughFavedPosts returns a list of Tags that the user hs favorites through a post

View File

@ -4,7 +4,7 @@ import (
"context"
"fmt"
"git.dragse.it/anthrove/otter-space-sdk/internal/relation"
"git.dragse.it/anthrove/otter-space-sdk/internal/relations"
"git.dragse.it/anthrove/otter-space-sdk/internal/user"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
)
@ -40,11 +40,11 @@ func (g *graphConnection) GetUserFavoriteCount(ctx context.Context, anthroveUser
}
func (g *graphConnection) CheckUserPostLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourcePostID string, sourceUrl string) (bool, error) {
return relation.CheckUserToPostLink(ctx, g.driver, anthroveUserID, sourcePostID, sourceUrl)
return relations.CheckUserToPostLink(ctx, g.driver, anthroveUserID, sourcePostID, sourceUrl)
}
func (g *graphConnection) LinkUserWithPost(ctx context.Context, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error {
return relation.EstablishUserToPostLink(ctx, g.driver, anthroveUser, anthrovePost)
return relations.EstablishUserToPostLink(ctx, g.driver, anthroveUser, anthrovePost)
}
func (g *graphConnection) GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error) {