Compare commits

...

13 Commits

Author SHA1 Message Date
e3a5adb2cc doc(source): added function documentation
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 15:37:44 +02:00
3e4560768b feat(source): added deletion
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 15:33:48 +02:00
a61c300b74 docs(post): added function documentation
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 15:27:05 +02:00
1017eaf5b8 docs(post): added function documentation
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 15:24:05 +02:00
fc73377d86 chore(post): code & folder restructure
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 15:08:24 +02:00
1075d45cb7 docs(post): added function documentation
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 15:05:47 +02:00
6d15d99563 chore(post): changed code layout
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 15:05:04 +02:00
5446f49a35 refactor(post): renamed functions & added documentation
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 15:03:38 +02:00
ca69008607 fix(post): query is now not missing a }
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 14:47:49 +02:00
6760948e73 feat(post): added deletion of posts & added some documentation for the add function as well
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 14:42:53 +02:00
6cabcf9beb refactor(models): reorganized structs
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 14:21:51 +02:00
0620d2919e docs(swagger): added typehint
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 14:18:36 +02:00
aa26357fec build(deps): bumped neo4j driver version
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-05-31 14:17:19 +02:00
22 changed files with 160 additions and 82 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module git.dragse.it/anthrove/otter-space-sdk
go 1.22.0
require (
github.com/neo4j/neo4j-go-driver/v5 v5.17.0
github.com/neo4j/neo4j-go-driver/v5 v5.20.0
github.com/sirupsen/logrus v1.9.3
)

4
go.sum
View File

@ -1,8 +1,8 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/neo4j/neo4j-go-driver/v5 v5.17.0 h1:Bdqg1Y8Hd3uLYToXtBjysDYXTdMiP7zeUNUEwfbJkSo=
github.com/neo4j/neo4j-go-driver/v5 v5.17.0/go.mod h1:Vff8OwT7QpLm7L2yYr85XNWe9Rbqlbeb9asNXJTHO4k=
github.com/neo4j/neo4j-go-driver/v5 v5.20.0 h1:XnoAi6g6XRkX+wxWa3yM+f7PT2VUkGQfBGtGuJL4fsM=
github.com/neo4j/neo4j-go-driver/v5 v5.20.0/go.mod h1:Vff8OwT7QpLm7L2yYr85XNWe9Rbqlbeb9asNXJTHO4k=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=

View File

@ -1,4 +1,4 @@
package internal
package post
import (
"context"
@ -8,6 +8,7 @@ import (
log "github.com/sirupsen/logrus"
)
// CreateAnthrovePostNode will always create a new node, it does not check if the node with the corresponding post_id and rating exists.
func CreateAnthrovePostNode(ctx context.Context, driver neo4j.DriverWithContext, anthrovePost *models.AnthrovePost) error {
query := `
CREATE (newPostNode:AnthrovePost {post_id: $anthrove_post_id, rating: $anthrove_rating})
@ -31,7 +32,31 @@ func CreateAnthrovePostNode(ctx context.Context, driver neo4j.DriverWithContext,
return nil
}
func CheckIfAnthrovePostNodeExistsByAnthroveID(ctx context.Context, driver neo4j.DriverWithContext, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error) {
// DeleteAnthrovePostNode will always delete a node, it only needs the anthrovePost.PostID filled out.
func DeleteAnthrovePostNode(ctx context.Context, driver neo4j.DriverWithContext, anthrovePost *models.AnthrovePost) error {
query := `
MATCH (anthrovePost:AnthrovePost {post_id: $anthrove_post_id})
DELETE anthrovePost
`
params := map[string]any{
"anthrove_post_id": anthrovePost.PostID,
}
_, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
if err != nil {
return err
}
log.WithFields(log.Fields{
"anthrove_post_id": anthrovePost.PostID,
}).Trace("graph: deleted anthrove post")
return nil
}
// 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 := `
OPTIONAL MATCH (postNode:AnthrovePost {post_id: $anthrove_post_id})
RETURN postNode.post_id AS AnthrovePostID
@ -49,7 +74,8 @@ func CheckIfAnthrovePostNodeExistsByAnthroveID(ctx context.Context, driver neo4j
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 := `
OPTIONAL MATCH (postNode:AnthrovePost)<-[:REFERENCE {url: $source_url}]-()
RETURN postNode.post_id AS AnthrovePostID
@ -66,7 +92,8 @@ func CheckIfAnthrovePostNodeExistsBySourceURl(ctx context.Context, driver neo4j.
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 := `
OPTIONAL MATCH (postNode:AnthrovePost)<-[:REFERENCE {source_post_id: $source_post_id}]-()
RETURN postNode.post_id AS AnthrovePostID

View File

@ -1,4 +1,4 @@
package internal
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

@ -1,4 +1,4 @@
package internal
package source
import (
"context"
@ -9,6 +9,7 @@ import (
log "github.com/sirupsen/logrus"
)
// CreateSourceNode will always create a new node, it checks if a node with the same url exits and merges it.
func CreateSourceNode(ctx context.Context, driver neo4j.DriverWithContext, anthroveSource *models.AnthroveSource) error {
query := `
MERGE (sourceNode:Source {domain: $source_url})
@ -34,6 +35,30 @@ func CreateSourceNode(ctx context.Context, driver neo4j.DriverWithContext, anthr
return nil
}
// DeleteSourceNode will delete a node with a given Domain
func DeleteSourceNode(ctx context.Context, driver neo4j.DriverWithContext, anthroveSource *models.AnthroveSource) error {
query := `
MERGE (sourceNode:Source {domain: $domain})
DELETE sourceNode
`
params := map[string]any{
"domain": anthroveSource.Domain,
}
_, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
if err != nil {
return fmt.Errorf("graph: %w", err)
}
log.WithFields(log.Fields{
"node_source_url": anthroveSource.Domain,
"node_source_displayName": anthroveSource.DisplayName,
"node_source_icon": anthroveSource.Icon,
}).Trace("graph: created source node")
return nil
}
func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]models.AnthroveSource, error) {
var sources []models.AnthroveSource
@ -75,8 +100,8 @@ func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]m
return sources, nil
}
// GetSourceNodesByURL returns the first models.AnthroveSource provided by the database
func GetSourceNodesByURL(ctx context.Context, driver neo4j.DriverWithContext, sourceUrl string) (*models.AnthroveSource, error) {
var source models.AnthroveSource
query := `

View File

@ -1,4 +1,4 @@
package internal
package tag
import (
"context"

View File

@ -1,4 +1,4 @@
package internal
package user
import (
"context"
@ -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

@ -1,4 +1,4 @@
package internal
package utils
import (
"fmt"

View File

@ -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)
}
}

View File

@ -2,16 +2,21 @@ package graph
import (
"context"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
)
type Post interface {
CreatePost(ctx context.Context, anthrovePost *models.AnthrovePost) error
DeletePost() 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
// CreatePost will always create a new node, it does not check if the node with the corresponding post_id and rating exists.
CreatePost(ctx context.Context, anthrovePost *models.AnthrovePost) error
// DeletePost will always delete a node, it only needs the anthrovePost.PostID filled out.
DeletePost(ctx context.Context, anthrovePost *models.AnthrovePost) error
// CheckPostNodeExistsBySourceID checks if a post node exists in the OtterSpace graph by its source ID.
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*models.AnthrovePost, bool, error)
// CheckPostNodeExistsByAnthroveID checks if a post node exists in the OtterSpace graph by its Anthrove ID.
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
@ -21,7 +26,6 @@ type Post interface {
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*models.AnthrovePost, bool, error)
// CheckPostNodeExistsBySourceID checks if a post node exists in the OtterSpace graph by its source ID.
// It returns the post if it exists, a boolean indicating whether the post was found, and an error if the operation fails.
CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*models.AnthrovePost, bool, error)
// LinkPostWithSource establishes a link between a post and a source in the OtterSpace graph.
LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error
}

View File

@ -2,31 +2,39 @@ 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/relations"
"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)
}
func (g *graphConnection) DeletePost() error {
//TODO implement me
panic("implement me")
}
func (g *graphConnection) CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error) {
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)
// 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 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.CheckIfAnthrovePostNodeExistsBySourceID(ctx, g.driver, sourcePostID)
return post.AnthroveNodeExistsBySourceID(ctx, g.driver, sourcePostID)
}
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)
// 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 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 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 relations.CreateAnthrovePostToSourceLink(ctx, g.driver, anthrovePostID, anthroveSourceDomain, anthrovePostRelationship)
}

View File

@ -2,14 +2,19 @@ package graph
import (
"context"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
)
type Source interface {
// CreateSource will always create a new node, it checks if a node with the same url exits and merges it.
CreateSource(ctx context.Context, anthroveSource *models.AnthroveSource) error
// DeleteSource will delete a node with a given Domain
DeleteSource(ctx context.Context, anthroveSource *models.AnthroveSource) error
// GetSourceByURL returns the Source Node based on the URL
// GetSourceByURL returns the first models.AnthroveSource provided by the database
GetSourceByURL(ctx context.Context, sourceUrl string) (*models.AnthroveSource, error)
// GetSourceLinkForUser retrieves the links between a user and sources in the OtterSpace graph.

View File

@ -2,31 +2,35 @@ 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"
)
// CreateSource will always create a new node, it checks if a node with the same url exits and merges it.
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)
}
// DeleteSource will delete a node with a given Domain
func (g *graphConnection) DeleteSource(ctx context.Context, anthroveSource *models.AnthroveSource) error {
//TODO implement me
panic("implement me")
return source.DeleteSourceNode(ctx, g.driver, anthroveSource)
}
// GetSourceByURL returns the first models.AnthroveSource provided by the database
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)
}

View File

@ -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)
}

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

@ -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/relations"
"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 relations.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 relations.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)
}

View File

@ -13,8 +13,3 @@ type FavoritePost struct {
type FavoriteList struct {
Posts []FavoritePost `json:"posts,omitempty"`
}
type TagsWithFrequency struct {
Frequency int64 `json:"frequency"`
Tags AnthroveTag `json:"tags"`
}

View File

@ -1,6 +1,6 @@
package models
type AnthrovePost struct {
PostID AnthrovePostID `json:"post_id"`
Rating AnthroveRating `json:"rating"`
PostID AnthrovePostID `json:"post_id" format:"string"`
Rating AnthroveRating `json:"rating" format:"string"`
}

View File

@ -1,12 +1,12 @@
package models
type AnthroveUserRelationship struct {
UserID string `json:"user_id"`
Username string `json:"username"`
ScrapeTimeInterval string `json:"scrape_time_interval"`
UserID string `json:"user_id" format:"string"`
Username string `json:"username" format:"string"`
ScrapeTimeInterval string `json:"scrape_time_interval" format:"string"`
Source AnthroveSource `json:"source"`
}
type AnthrovePostRelationship struct {
PostID string `json:"post_id"`
Url string `json:"url"`
PostID string `json:"post_id" format:"string"`
Url string `json:"url" format:"string"`
}

View File

@ -1,7 +1,7 @@
package models
type AnthroveSource struct {
DisplayName string `json:"display_name"`
Domain string `json:"domain"`
Icon string `json:"icon"`
DisplayName string `json:"display_name" format:"string"`
Domain string `json:"domain" format:"string"`
Icon string `json:"icon" format:"string"`
}

View File

@ -1,6 +1,11 @@
package models
type AnthroveTag struct {
Name string `json:"name"`
Type string `json:"type"`
Name string `json:"name" format:"string"`
Type string `json:"type" format:"string"`
}
type TagsWithFrequency struct {
Frequency int64 `json:"frequency"`
Tags AnthroveTag `json:"tags"`
}

View File

@ -1,6 +1,6 @@
package models
type AnthroveUser struct {
UserID AnthroveUserID `json:"user_id"`
UserID AnthroveUserID `json:"user_id" format:"string"`
Relationship []AnthroveUserRelationship `json:"relationship"`
}