docs(post): added function documentation
Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
parent
fc73377d86
commit
1017eaf5b8
@ -1,4 +1,4 @@
|
|||||||
package relation
|
package relations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -9,7 +9,8 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
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 := `
|
query := `
|
||||||
MATCH (sourceNode:Source {domain: $source_url})
|
MATCH (sourceNode:Source {domain: $source_url})
|
||||||
MATCH (postNode:AnthrovePost {post_id: $anthrove_post_id})
|
MATCH (postNode:AnthrovePost {post_id: $anthrove_post_id})
|
@ -217,8 +217,8 @@ func GetAnthroveUser(ctx context.Context, driver neo4j.DriverWithContext, anthro
|
|||||||
userRelationships := make([]models.AnthroveUserRelationship, 0)
|
userRelationships := make([]models.AnthroveUserRelationship, 0)
|
||||||
|
|
||||||
query := `
|
query := `
|
||||||
MATCH (user:User{user_id: $anthrove_user_id})-[relation:HAS_ACCOUNT_AT]->(source:Source)
|
MATCH (user:User{user_id: $anthrove_user_id})-[relations:HAS_ACCOUNT_AT]->(source:Source)
|
||||||
RETURN user as User, relation as Relation, source as Source;
|
RETURN user as User, relations as Relation, source as Source;
|
||||||
`
|
`
|
||||||
params := map[string]any{
|
params := map[string]any{
|
||||||
"anthrove_user_id": anthroveUserID,
|
"anthrove_user_id": anthroveUserID,
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/internal/post"
|
"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"
|
"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)
|
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 {
|
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)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package graph
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
"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.
|
// It returns the user and an error if the operation fails.
|
||||||
GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*models.AnthroveUser, error)
|
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)
|
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
|
// GetUserTagsTroughFavedPosts returns a list of Tags that the user hs favorites through a post
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"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/internal/user"
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
"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) {
|
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 {
|
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) {
|
func (g *graphConnection) GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error) {
|
||||||
|
Reference in New Issue
Block a user