refactor(post): renamed functions & added documentation
Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
parent
ca69008607
commit
5446f49a35
@ -55,7 +55,8 @@ func DeleteAnthrovePostNode(ctx context.Context, driver neo4j.DriverWithContext,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckIfAnthrovePostNodeExistsByAnthroveID(ctx context.Context, driver neo4j.DriverWithContext, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error) {
|
// AnthroveNodeExistsByAnthroveID checks if a models.AnthrovePost exists by its models.AnthrovePostID.
|
||||||
|
func AnthroveNodeExistsByAnthroveID(ctx context.Context, driver neo4j.DriverWithContext, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error) {
|
||||||
query := `
|
query := `
|
||||||
OPTIONAL MATCH (postNode:AnthrovePost {post_id: $anthrove_post_id})
|
OPTIONAL MATCH (postNode:AnthrovePost {post_id: $anthrove_post_id})
|
||||||
RETURN postNode.post_id AS AnthrovePostID
|
RETURN postNode.post_id AS AnthrovePostID
|
||||||
@ -73,7 +74,8 @@ func CheckIfAnthrovePostNodeExistsByAnthroveID(ctx context.Context, driver neo4j
|
|||||||
return anthrovePost, exists, nil
|
return anthrovePost, exists, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckIfAnthrovePostNodeExistsBySourceURl(ctx context.Context, driver neo4j.DriverWithContext, sourceUrl string) (*models.AnthrovePost, bool, error) {
|
// AnthroveNodeExistsBySourceURL checks if a models.AnthrovePost exists by its sourceUrl.
|
||||||
|
func AnthroveNodeExistsBySourceURL(ctx context.Context, driver neo4j.DriverWithContext, sourceUrl string) (*models.AnthrovePost, bool, error) {
|
||||||
query := `
|
query := `
|
||||||
OPTIONAL MATCH (postNode:AnthrovePost)<-[:REFERENCE {url: $source_url}]-()
|
OPTIONAL MATCH (postNode:AnthrovePost)<-[:REFERENCE {url: $source_url}]-()
|
||||||
RETURN postNode.post_id AS AnthrovePostID
|
RETURN postNode.post_id AS AnthrovePostID
|
||||||
@ -90,7 +92,8 @@ func CheckIfAnthrovePostNodeExistsBySourceURl(ctx context.Context, driver neo4j.
|
|||||||
return anthrovePost, exists, nil
|
return anthrovePost, exists, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckIfAnthrovePostNodeExistsBySourceID(ctx context.Context, driver neo4j.DriverWithContext, sourcePostID string) (*models.AnthrovePost, bool, error) {
|
// AnthroveNodeExistsBySourceID checks if a models.AnthrovePost exists by its sourcePostID.
|
||||||
|
func AnthroveNodeExistsBySourceID(ctx context.Context, driver neo4j.DriverWithContext, sourcePostID string) (*models.AnthrovePost, bool, error) {
|
||||||
query := `
|
query := `
|
||||||
OPTIONAL MATCH (postNode:AnthrovePost)<-[:REFERENCE {source_post_id: $source_post_id}]-()
|
OPTIONAL MATCH (postNode:AnthrovePost)<-[:REFERENCE {source_post_id: $source_post_id}]-()
|
||||||
RETURN postNode.post_id AS AnthrovePostID
|
RETURN postNode.post_id AS AnthrovePostID
|
||||||
|
@ -18,16 +18,19 @@ func (g *graphConnection) DeletePost(ctx context.Context, anthrovePost *models.A
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *graphConnection) CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error) {
|
// CheckPostNodeExistsBySourceID checks if a models.AnthrovePost exists by its sourcePostID.
|
||||||
return internal.CheckIfAnthrovePostNodeExistsByAnthroveID(ctx, g.driver, anthrovePost)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *graphConnection) CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*models.AnthrovePost, bool, error) {
|
|
||||||
return internal.CheckIfAnthrovePostNodeExistsBySourceURl(ctx, g.driver, sourceUrl)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *graphConnection) CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*models.AnthrovePost, bool, error) {
|
func (g *graphConnection) CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*models.AnthrovePost, bool, error) {
|
||||||
return internal.CheckIfAnthrovePostNodeExistsBySourceID(ctx, g.driver, sourcePostID)
|
return internal.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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
Reference in New Issue
Block a user