BREAKING CHANGE: V2 of thr SDK #12
@ -2,13 +2,13 @@ package graph
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func CreateAnthrovePostNode(ctx context.Context, driver neo4j.DriverWithContext, anthrovePost *models.AnthrovePost) error {
|
||||
func CreateAnthrovePostNode(ctx context.Context, driver neo4j.DriverWithContext, anthrovePost *graphModels.AnthrovePost) error {
|
||||
query := `
|
||||
CREATE (newPostNode:AnthrovePost {post_id: $anthrove_post_id, rating: $anthrove_rating})
|
||||
`
|
||||
@ -31,7 +31,7 @@ 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) {
|
||||
func CheckIfAnthrovePostNodeExistsByAnthroveID(ctx context.Context, driver neo4j.DriverWithContext, anthrovePost *graphModels.AnthrovePost) (*graphModels.AnthrovePost, bool, error) {
|
||||
query := `
|
||||
OPTIONAL MATCH (postNode:AnthrovePost {post_id: $anthrove_post_id})
|
||||
RETURN postNode.post_id AS AnthrovePostID
|
||||
@ -49,7 +49,7 @@ 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) {
|
||||
func CheckIfAnthrovePostNodeExistsBySourceURl(ctx context.Context, driver neo4j.DriverWithContext, sourceUrl string) (*graphModels.AnthrovePost, bool, error) {
|
||||
query := `
|
||||
OPTIONAL MATCH (postNode:AnthrovePost)<-[:REFERENCE {url: $source_url}]-()
|
||||
RETURN postNode.post_id AS AnthrovePostID
|
||||
@ -66,7 +66,7 @@ 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) {
|
||||
func CheckIfAnthrovePostNodeExistsBySourceID(ctx context.Context, driver neo4j.DriverWithContext, sourcePostID string) (*graphModels.AnthrovePost, bool, error) {
|
||||
query := `
|
||||
OPTIONAL MATCH (postNode:AnthrovePost)<-[:REFERENCE {source_post_id: $source_post_id}]-()
|
||||
RETURN postNode.post_id AS AnthrovePostID
|
||||
@ -84,9 +84,9 @@ func CheckIfAnthrovePostNodeExistsBySourceID(ctx context.Context, driver neo4j.D
|
||||
return anthrovePost, exists, nil
|
||||
}
|
||||
|
||||
func executeCheckQuery(ctx context.Context, driver neo4j.DriverWithContext, query string, params map[string]any) (*models.AnthrovePost, bool, error) {
|
||||
func executeCheckQuery(ctx context.Context, driver neo4j.DriverWithContext, query string, params map[string]any) (*graphModels.AnthrovePost, bool, error) {
|
||||
|
||||
var anthrovePost models.AnthrovePost
|
||||
var anthrovePost graphModels.AnthrovePost
|
||||
|
||||
result, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
|
||||
if err != nil {
|
||||
|
@ -3,13 +3,13 @@ package graph
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func EstablishAnthrovePostToSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error {
|
||||
func EstablishAnthrovePostToSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *graphModels.AnthrovePostRelationship) error {
|
||||
query := `
|
||||
MATCH (sourceNode:Source {domain: $source_url})
|
||||
MATCH (postNode:AnthrovePost {post_id: $anthrove_post_id})
|
||||
@ -38,7 +38,7 @@ func EstablishAnthrovePostToSourceLink(ctx context.Context, driver neo4j.DriverW
|
||||
return nil
|
||||
}
|
||||
|
||||
func EstablishUserToPostLink(ctx context.Context, driver neo4j.DriverWithContext, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error {
|
||||
func EstablishUserToPostLink(ctx context.Context, driver neo4j.DriverWithContext, anthroveUser *graphModels.AnthroveUser, anthrovePost *graphModels.AnthrovePost) error {
|
||||
|
||||
query := `
|
||||
MATCH (user:User {user_id: $anthrove_user_id})
|
||||
|
@ -3,13 +3,13 @@ package graph
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
|
||||
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func CreateSourceNode(ctx context.Context, driver neo4j.DriverWithContext, anthroveSource *models.AnthroveSource) error {
|
||||
func CreateSourceNode(ctx context.Context, driver neo4j.DriverWithContext, anthroveSource *graphModels.AnthroveSource) error {
|
||||
query := `
|
||||
MERGE (sourceNode:Source {domain: $source_url})
|
||||
ON CREATE SET sourceNode.domain = $source_url, sourceNode.display_name = $source_display_name, sourceNode.icon = $source_icon
|
||||
@ -34,8 +34,8 @@ func CreateSourceNode(ctx context.Context, driver neo4j.DriverWithContext, anthr
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]models.AnthroveSource, error) {
|
||||
var sources []models.AnthroveSource
|
||||
func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]graphModels.AnthroveSource, error) {
|
||||
var sources []graphModels.AnthroveSource
|
||||
|
||||
query := `
|
||||
MATCH (s:Source)
|
||||
@ -60,7 +60,7 @@ func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]m
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sources = append(sources, models.AnthroveSource{
|
||||
sources = append(sources, graphModels.AnthroveSource{
|
||||
DisplayName: source.Props["display_name"].(string),
|
||||
Domain: source.Props["domain"].(string),
|
||||
Icon: source.Props["icon"].(string),
|
||||
@ -75,9 +75,9 @@ func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]m
|
||||
return sources, nil
|
||||
}
|
||||
|
||||
func GetSourceNodesByURL(ctx context.Context, driver neo4j.DriverWithContext, sourceUrl string) (*models.AnthroveSource, error) {
|
||||
func GetSourceNodesByURL(ctx context.Context, driver neo4j.DriverWithContext, sourceUrl string) (*graphModels.AnthroveSource, error) {
|
||||
|
||||
var source models.AnthroveSource
|
||||
var source graphModels.AnthroveSource
|
||||
|
||||
query := `
|
||||
MATCH (s:Source {domain: $source_url})
|
||||
|
@ -2,13 +2,13 @@ package graph
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func CreateTagNodeWitRelation(ctx context.Context, driver neo4j.DriverWithContext, anthrovePostID models.AnthrovePostID, anthroveTag *models.AnthroveTag) error {
|
||||
func CreateTagNodeWitRelation(ctx context.Context, driver neo4j.DriverWithContext, anthrovePostID models.AnthrovePostID, anthroveTag *graphModels.AnthroveTag) error {
|
||||
query := `
|
||||
MATCH (anthrovePost:AnthrovePost {post_id: $anthrove_post_id})
|
||||
MERGE (tagNode:Tag {name: $tag_name, type: $tag_type})
|
||||
@ -34,8 +34,8 @@ func CreateTagNodeWitRelation(ctx context.Context, driver neo4j.DriverWithContex
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetTags(ctx context.Context, driver neo4j.DriverWithContext) ([]models.TagsWithFrequency, error) {
|
||||
var userTags []models.TagsWithFrequency
|
||||
func GetTags(ctx context.Context, driver neo4j.DriverWithContext) ([]graphModels.TagsWithFrequency, error) {
|
||||
var userTags []graphModels.TagsWithFrequency
|
||||
|
||||
query := `
|
||||
MATCH (:AnthrovePost)-[:HAS]->(t:Tag)
|
||||
@ -66,9 +66,9 @@ func GetTags(ctx context.Context, driver neo4j.DriverWithContext) ([]models.Tags
|
||||
return nil, err
|
||||
}
|
||||
|
||||
userTags = append(userTags, models.TagsWithFrequency{
|
||||
userTags = append(userTags, graphModels.TagsWithFrequency{
|
||||
Frequency: frequency,
|
||||
Tags: models.AnthroveTag{
|
||||
Tags: graphModels.AnthroveTag{
|
||||
Name: tag.Props["name"].(string),
|
||||
Type: tag.Props["type"].(string),
|
||||
},
|
||||
|
@ -3,9 +3,9 @@ package graph
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.dragse.it/anthrove/otter-space-sdk/internal/utils"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -28,13 +28,13 @@ func CreateUserNodeWithSourceRelation(ctx context.Context, driver neo4j.DriverWi
|
||||
return err
|
||||
}
|
||||
|
||||
var anthroveUserRelationship []models.AnthroveUserRelationship
|
||||
var anthroveUserRelationship []graphModels.AnthroveUserRelationship
|
||||
|
||||
anthroveUserRelationship = append(anthroveUserRelationship, models.AnthroveUserRelationship{
|
||||
anthroveUserRelationship = append(anthroveUserRelationship, graphModels.AnthroveUserRelationship{
|
||||
UserID: userID,
|
||||
Username: username,
|
||||
ScrapeTimeInterval: "",
|
||||
Source: models.AnthroveSource{
|
||||
Source: graphModels.AnthroveSource{
|
||||
DisplayName: "",
|
||||
Domain: sourceDomain,
|
||||
Icon: "",
|
||||
@ -90,9 +90,9 @@ func GetUserFavoritesCount(ctx context.Context, driver neo4j.DriverWithContext,
|
||||
return userFavoriteCount, nil
|
||||
}
|
||||
|
||||
func GetUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error) {
|
||||
func GetUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID) (map[string]graphModels.AnthroveUserRelationship, error) {
|
||||
|
||||
userSource := make(map[string]models.AnthroveUserRelationship)
|
||||
userSource := make(map[string]graphModels.AnthroveUserRelationship)
|
||||
|
||||
query := `
|
||||
MATCH (user:User{user_id: $anthrove_user_id})-[r:HAS_ACCOUNT_AT]->(s:Source)
|
||||
@ -130,10 +130,10 @@ func GetUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anth
|
||||
domain := source.Props["domain"].(string)
|
||||
icon := source.Props["icon"].(string)
|
||||
|
||||
anthroveSourceUser := models.AnthroveUserRelationship{
|
||||
anthroveSourceUser := graphModels.AnthroveUserRelationship{
|
||||
UserID: sourceUserID,
|
||||
Username: sourceUsername,
|
||||
Source: models.AnthroveSource{
|
||||
Source: graphModels.AnthroveSource{
|
||||
DisplayName: displayName,
|
||||
Domain: domain,
|
||||
Icon: icon,
|
||||
@ -150,9 +150,9 @@ func GetUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anth
|
||||
return userSource, nil
|
||||
}
|
||||
|
||||
func GetSpecifiedUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]models.AnthroveUserRelationship, error) {
|
||||
func GetSpecifiedUserSourceLink(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]graphModels.AnthroveUserRelationship, error) {
|
||||
|
||||
userSource := make(map[string]models.AnthroveUserRelationship)
|
||||
userSource := make(map[string]graphModels.AnthroveUserRelationship)
|
||||
|
||||
query := `
|
||||
MATCH (user:User{user_id: $anthrove_user_id})-[r:HAS_ACCOUNT_AT]->(s:Source{display_name: $source_display_name})
|
||||
@ -191,10 +191,10 @@ func GetSpecifiedUserSourceLink(ctx context.Context, driver neo4j.DriverWithCont
|
||||
domain := source.Props["domain"].(string)
|
||||
icon := source.Props["icon"].(string)
|
||||
|
||||
anthroveSourceUser := models.AnthroveUserRelationship{
|
||||
anthroveSourceUser := graphModels.AnthroveUserRelationship{
|
||||
UserID: sourceUserID,
|
||||
Username: sourceUsername,
|
||||
Source: models.AnthroveSource{
|
||||
Source: graphModels.AnthroveSource{
|
||||
DisplayName: displayName,
|
||||
Domain: domain,
|
||||
Icon: icon,
|
||||
@ -211,11 +211,11 @@ func GetSpecifiedUserSourceLink(ctx context.Context, driver neo4j.DriverWithCont
|
||||
return userSource, nil
|
||||
}
|
||||
|
||||
func GetAnthroveUser(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID) (*models.AnthroveUser, error) {
|
||||
func GetAnthroveUser(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID) (*graphModels.AnthroveUser, error) {
|
||||
var err error
|
||||
var anthroveUser models.AnthroveUser
|
||||
var userSources models.AnthroveSource
|
||||
userRelationships := make([]models.AnthroveUserRelationship, 0)
|
||||
var anthroveUser graphModels.AnthroveUser
|
||||
var userSources graphModels.AnthroveSource
|
||||
userRelationships := make([]graphModels.AnthroveUserRelationship, 0)
|
||||
|
||||
query := `
|
||||
MATCH (user:User{user_id: $anthrove_user_id})-[relation:HAS_ACCOUNT_AT]->(source:Source)
|
||||
@ -250,13 +250,13 @@ func GetAnthroveUser(ctx context.Context, driver neo4j.DriverWithContext, anthro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
userRelationships = append(userRelationships, models.AnthroveUserRelationship{
|
||||
userRelationships = append(userRelationships, graphModels.AnthroveUserRelationship{
|
||||
UserID: fmt.Sprintf("%v", utils.GetOrDefault(relation.Props, "user_id", "")),
|
||||
Username: utils.GetOrDefault(relation.Props, "username", "").(string),
|
||||
ScrapeTimeInterval: utils.GetOrDefault(relation.Props, "scrape_time_interval", "").(string),
|
||||
})
|
||||
|
||||
userSources = models.AnthroveSource{
|
||||
userSources = graphModels.AnthroveSource{
|
||||
DisplayName: utils.GetOrDefault(source.Props, "display_name", "").(string),
|
||||
Domain: utils.GetOrDefault(source.Props, "domain", "").(string),
|
||||
Icon: utils.GetOrDefault(source.Props, "icon", "").(string),
|
||||
@ -316,9 +316,9 @@ func GetAllAnthroveUserIDs(ctx context.Context, driver neo4j.DriverWithContext)
|
||||
|
||||
}
|
||||
|
||||
func GetUserFavoriteNodeWithPagination(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID, skip int, limit int) (*models.FavoriteList, error) {
|
||||
func GetUserFavoriteNodeWithPagination(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID, skip int, limit int) (*graphModels.FavoriteList, error) {
|
||||
var err error
|
||||
var favoritePosts []models.FavoritePost
|
||||
var favoritePosts []graphModels.FavoritePost
|
||||
|
||||
query := `
|
||||
CALL {
|
||||
@ -368,22 +368,22 @@ func GetUserFavoriteNodeWithPagination(ctx context.Context, driver neo4j.DriverW
|
||||
}
|
||||
|
||||
if len(favoritePosts) != 0 && favoritePosts[len(favoritePosts)-1].AnthrovePost.PostID == models.AnthrovePostID(anthrovePost.Props["post_id"].(string)) {
|
||||
favoritePosts[len(favoritePosts)-1].Relations = append(favoritePosts[len(favoritePosts)-1].Relations, models.FavoriteRelations{
|
||||
favoritePosts[len(favoritePosts)-1].Relations = append(favoritePosts[len(favoritePosts)-1].Relations, graphModels.FavoriteRelations{
|
||||
SourcesID: source.Props["display_name"].(string),
|
||||
Relations: models.AnthrovePostRelationship{
|
||||
Relations: graphModels.AnthrovePostRelationship{
|
||||
PostID: postRelation.Props["source_post_id"].(string),
|
||||
Url: postRelation.Props["url"].(string),
|
||||
},
|
||||
})
|
||||
} else {
|
||||
favoritePosts = append(favoritePosts, models.FavoritePost{
|
||||
AnthrovePost: models.AnthrovePost{
|
||||
favoritePosts = append(favoritePosts, graphModels.FavoritePost{
|
||||
AnthrovePost: graphModels.AnthrovePost{
|
||||
PostID: models.AnthrovePostID(anthrovePost.Props["post_id"].(string)),
|
||||
Rating: models.AnthroveRating(anthrovePost.Props["rating"].(string)),
|
||||
Rating: models.Rating(anthrovePost.Props["rating"].(string)),
|
||||
},
|
||||
Relations: []models.FavoriteRelations{{
|
||||
Relations: []graphModels.FavoriteRelations{{
|
||||
SourcesID: source.Props["display_name"].(string),
|
||||
Relations: models.AnthrovePostRelationship{
|
||||
Relations: graphModels.AnthrovePostRelationship{
|
||||
PostID: postRelation.Props["source_post_id"].(string),
|
||||
Url: postRelation.Props["url"].(string),
|
||||
},
|
||||
@ -398,12 +398,12 @@ func GetUserFavoriteNodeWithPagination(ctx context.Context, driver neo4j.DriverW
|
||||
"anthrove_user_fav_count": len(favoritePosts),
|
||||
}).Trace("database: got al anthrove user favorites")
|
||||
|
||||
return &models.FavoriteList{Posts: favoritePosts}, nil
|
||||
return &graphModels.FavoriteList{Posts: favoritePosts}, nil
|
||||
|
||||
}
|
||||
|
||||
func GetUserTagNodeWitRelationToFavedPosts(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID) ([]models.TagsWithFrequency, error) {
|
||||
var userTags []models.TagsWithFrequency
|
||||
func GetUserTagNodeWitRelationToFavedPosts(ctx context.Context, driver neo4j.DriverWithContext, anthroveUserID models.AnthroveUserID) ([]graphModels.TagsWithFrequency, error) {
|
||||
var userTags []graphModels.TagsWithFrequency
|
||||
|
||||
query := `
|
||||
MATCH (u:User {user_id: $anthrove_user_id})-[:FAV]->(:AnthrovePost)-[:HAS]->(t:Tag)
|
||||
@ -436,9 +436,9 @@ func GetUserTagNodeWitRelationToFavedPosts(ctx context.Context, driver neo4j.Dri
|
||||
return nil, err
|
||||
}
|
||||
|
||||
userTags = append(userTags, models.TagsWithFrequency{
|
||||
userTags = append(userTags, graphModels.TagsWithFrequency{
|
||||
Frequency: frequency,
|
||||
Tags: models.AnthroveTag{
|
||||
Tags: graphModels.AnthroveTag{
|
||||
Name: tag.Props["name"].(string),
|
||||
Type: tag.Props["type"].(string),
|
||||
},
|
||||
|
@ -2,14 +2,14 @@ package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// GetAllSourceNodes returns a list of all models.AnthroveSource
|
||||
func GetAllSourceNodes(ctx context.Context, db *gorm.DB) ([]models.AnthroveSource, error) {
|
||||
var sources []models.AnthroveSource
|
||||
func GetAllSourceNodes(ctx context.Context, db *gorm.DB) ([]graphModels.AnthroveSource, error) {
|
||||
var sources []graphModels.AnthroveSource
|
||||
|
||||
result := db.WithContext(ctx).Find(&sources)
|
||||
|
||||
|
@ -27,8 +27,8 @@ package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
|
||||
)
|
||||
|
||||
// OtterSpace provides an interface for interacting with the OtterSpace API.
|
||||
@ -45,23 +45,23 @@ type OtterSpace interface {
|
||||
|
||||
// AddSource adds a new source to the OtterSpace database.
|
||||
// It returns an error if the operation fails.
|
||||
AddSource(ctx context.Context, anthroveSource *models.AnthroveSource) error
|
||||
AddSource(ctx context.Context, anthroveSource *graphModels.AnthroveSource) error
|
||||
|
||||
// AddPost adds a new post to the OtterSpace database.
|
||||
// It returns an error if the operation fails.
|
||||
AddPost(ctx context.Context, anthrovePost *models.AnthrovePost) error
|
||||
AddPost(ctx context.Context, anthrovePost *graphModels.AnthrovePost) error
|
||||
|
||||
// AddTagWithRelationToPost adds a new tag to the OtterSpace database and associates it with a post.
|
||||
// It returns an error if the operation fails.
|
||||
AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.AnthroveTag) error
|
||||
AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *graphModels.AnthroveTag) error
|
||||
|
||||
// LinkPostWithSource establishes a link between a post and a source in the OtterSpace database.
|
||||
// It returns an error if the operation fails.
|
||||
LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error
|
||||
LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *graphModels.AnthrovePostRelationship) error
|
||||
|
||||
// LinkUserWithPost establishes a link between a user and a post in the OtterSpace database.
|
||||
// It returns an error if the operation fails.
|
||||
LinkUserWithPost(ctx context.Context, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error
|
||||
LinkUserWithPost(ctx context.Context, anthroveUser *graphModels.AnthroveUser, anthrovePost *graphModels.AnthrovePost) error
|
||||
|
||||
// CheckUserPostLink checks if a link between a user and a post exists in the OtterSpace database.
|
||||
// It returns true if the link exists, false otherwise, and an error if the operation fails.
|
||||
@ -69,15 +69,15 @@ type OtterSpace interface {
|
||||
|
||||
// CheckPostNodeExistsByAnthroveID checks if a post node exists in the OtterSpace database 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.
|
||||
CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error)
|
||||
CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *graphModels.AnthrovePost) (*graphModels.AnthrovePost, bool, error)
|
||||
|
||||
// CheckPostNodeExistsBySourceURL checks if a post node exists in the OtterSpace database by its source URL.
|
||||
// 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)
|
||||
CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*graphModels.AnthrovePost, bool, error)
|
||||
|
||||
// CheckPostNodeExistsBySourceID checks if a post node exists in the OtterSpace database 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)
|
||||
CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*graphModels.AnthrovePost, bool, error)
|
||||
|
||||
// GetUserFavoriteCount retrieves the count of a user's favorite posts from the OtterSpace database.
|
||||
// It returns the count and an error if the operation fails.
|
||||
@ -85,32 +85,32 @@ type OtterSpace interface {
|
||||
|
||||
// GetUserSourceLinks retrieves the links between a user and sources in the OtterSpace database.
|
||||
// It returns a map of source domains to user-source relationships, and an error if the operation fails.
|
||||
GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error)
|
||||
GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]graphModels.AnthroveUserRelationship, error)
|
||||
|
||||
// GetSpecifiedUserSourceLink GetUserSourceLinks retrieves the links between a user and a specific source in the OtterSpace database.
|
||||
// It returns a map of source domains to user-source relationships, and an error if the operation fails.
|
||||
GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]models.AnthroveUserRelationship, error)
|
||||
GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]graphModels.AnthroveUserRelationship, error)
|
||||
|
||||
// GetAnthroveUser retrieves a user from the OtterSpace database by their ID.
|
||||
// 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) (*graphModels.AnthroveUser, error)
|
||||
|
||||
// GetAllAnthroveUserIDs retrieves all user IDs from the OtterSpace database.
|
||||
// It returns a slice of user IDs and an error if the operation fails.
|
||||
GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error)
|
||||
|
||||
// GetUserFavoritePostsWithPagination gets all user favorites with relation 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) (*graphModels.FavoriteList, error)
|
||||
|
||||
// GetUserTagsTroughFavedPosts returns a list of Tags that the user hs favorites through a post
|
||||
GetUserTagsTroughFavedPosts(ctx context.Context, anthroveUserID models.AnthroveUserID) ([]models.TagsWithFrequency, error)
|
||||
GetUserTagsTroughFavedPosts(ctx context.Context, anthroveUserID models.AnthroveUserID) ([]graphModels.TagsWithFrequency, error)
|
||||
|
||||
// GetAllTags returns a list of Tags that the user hs favorites through a post
|
||||
GetAllTags(ctx context.Context) ([]models.TagsWithFrequency, error)
|
||||
GetAllTags(ctx context.Context) ([]graphModels.TagsWithFrequency, error)
|
||||
|
||||
// GetAllSources returns a list of Sources in the database
|
||||
GetAllSources(ctx context.Context) ([]models.AnthroveSource, error)
|
||||
GetAllSources(ctx context.Context) ([]graphModels.AnthroveSource, error)
|
||||
|
||||
// GetSourceByURL returns the Source Node based on the URL
|
||||
GetSourceByURL(ctx context.Context, sourceUrl string) (*models.AnthroveSource, error)
|
||||
GetSourceByURL(ctx context.Context, sourceUrl string) (*graphModels.AnthroveSource, error)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/internal/graph"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j/config"
|
||||
)
|
||||
@ -39,23 +40,23 @@ func (g *graphConnection) AddUserWithRelationToSource(ctx context.Context, anthr
|
||||
return graph.CreateUserNodeWithSourceRelation(ctx, g.driver, anthroveUserID, sourceDomain, userID, username)
|
||||
}
|
||||
|
||||
func (g *graphConnection) AddSource(ctx context.Context, anthroveSource *models.AnthroveSource) error {
|
||||
func (g *graphConnection) AddSource(ctx context.Context, anthroveSource *graphModels.AnthroveSource) error {
|
||||
return graph.CreateSourceNode(ctx, g.driver, anthroveSource)
|
||||
}
|
||||
|
||||
func (g *graphConnection) AddPost(ctx context.Context, anthrovePost *models.AnthrovePost) error {
|
||||
func (g *graphConnection) AddPost(ctx context.Context, anthrovePost *graphModels.AnthrovePost) error {
|
||||
return graph.CreateAnthrovePostNode(ctx, g.driver, anthrovePost)
|
||||
}
|
||||
|
||||
func (g *graphConnection) AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.AnthroveTag) error {
|
||||
func (g *graphConnection) AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *graphModels.AnthroveTag) error {
|
||||
return graph.CreateTagNodeWitRelation(ctx, g.driver, anthrovePostID, anthroveTag)
|
||||
}
|
||||
|
||||
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 *graphModels.AnthrovePostRelationship) error {
|
||||
return graph.EstablishAnthrovePostToSourceLink(ctx, g.driver, anthrovePostID, anthroveSourceDomain, anthrovePostRelationship)
|
||||
}
|
||||
|
||||
func (g *graphConnection) LinkUserWithPost(ctx context.Context, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error {
|
||||
func (g *graphConnection) LinkUserWithPost(ctx context.Context, anthroveUser *graphModels.AnthroveUser, anthrovePost *graphModels.AnthrovePost) error {
|
||||
return graph.EstablishUserToPostLink(ctx, g.driver, anthroveUser, anthrovePost)
|
||||
}
|
||||
|
||||
@ -63,15 +64,15 @@ func (g *graphConnection) CheckUserPostLink(ctx context.Context, anthroveUserID
|
||||
return graph.CheckUserToPostLink(ctx, g.driver, anthroveUserID, sourcePostID, sourceUrl)
|
||||
}
|
||||
|
||||
func (g *graphConnection) CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error) {
|
||||
func (g *graphConnection) CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *graphModels.AnthrovePost) (*graphModels.AnthrovePost, bool, error) {
|
||||
return graph.CheckIfAnthrovePostNodeExistsByAnthroveID(ctx, g.driver, anthrovePost)
|
||||
}
|
||||
|
||||
func (g *graphConnection) CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*models.AnthrovePost, bool, error) {
|
||||
func (g *graphConnection) CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*graphModels.AnthrovePost, bool, error) {
|
||||
return graph.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) (*graphModels.AnthrovePost, bool, error) {
|
||||
return graph.CheckIfAnthrovePostNodeExistsBySourceID(ctx, g.driver, sourcePostID)
|
||||
}
|
||||
|
||||
@ -79,15 +80,15 @@ func (g *graphConnection) GetUserFavoriteCount(ctx context.Context, anthroveUser
|
||||
return graph.GetUserFavoritesCount(ctx, g.driver, anthroveUserID)
|
||||
}
|
||||
|
||||
func (g *graphConnection) GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error) {
|
||||
func (g *graphConnection) GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]graphModels.AnthroveUserRelationship, error) {
|
||||
return graph.GetUserSourceLink(ctx, g.driver, anthroveUserID)
|
||||
}
|
||||
|
||||
func (g *graphConnection) GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]models.AnthroveUserRelationship, error) {
|
||||
func (g *graphConnection) GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]graphModels.AnthroveUserRelationship, error) {
|
||||
return graph.GetSpecifiedUserSourceLink(ctx, g.driver, anthroveUserID, sourceDisplayName)
|
||||
}
|
||||
|
||||
func (g *graphConnection) GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*models.AnthroveUser, error) {
|
||||
func (g *graphConnection) GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*graphModels.AnthroveUser, error) {
|
||||
return graph.GetAnthroveUser(ctx, g.driver, anthroveUserID)
|
||||
}
|
||||
|
||||
@ -95,23 +96,23 @@ func (g *graphConnection) GetAllAnthroveUserIDs(ctx context.Context) ([]models.A
|
||||
return graph.GetAllAnthroveUserIDs(ctx, g.driver)
|
||||
}
|
||||
|
||||
func (g *graphConnection) GetUserFavoritePostsWithPagination(ctx context.Context, anthroveUserID models.AnthroveUserID, skip int, limit int) (*models.FavoriteList, error) {
|
||||
func (g *graphConnection) GetUserFavoritePostsWithPagination(ctx context.Context, anthroveUserID models.AnthroveUserID, skip int, limit int) (*graphModels.FavoriteList, error) {
|
||||
return graph.GetUserFavoriteNodeWithPagination(ctx, g.driver, anthroveUserID, skip, limit)
|
||||
}
|
||||
|
||||
func (g *graphConnection) GetUserTagsTroughFavedPosts(ctx context.Context, anthroveUserID models.AnthroveUserID) ([]models.TagsWithFrequency, error) {
|
||||
func (g *graphConnection) GetUserTagsTroughFavedPosts(ctx context.Context, anthroveUserID models.AnthroveUserID) ([]graphModels.TagsWithFrequency, error) {
|
||||
return graph.GetUserTagNodeWitRelationToFavedPosts(ctx, g.driver, anthroveUserID)
|
||||
}
|
||||
|
||||
func (g *graphConnection) GetAllTags(ctx context.Context) ([]models.TagsWithFrequency, error) {
|
||||
func (g *graphConnection) GetAllTags(ctx context.Context) ([]graphModels.TagsWithFrequency, error) {
|
||||
return graph.GetTags(ctx, g.driver)
|
||||
}
|
||||
|
||||
func (g *graphConnection) GetAllSources(ctx context.Context) ([]models.AnthroveSource, error) {
|
||||
func (g *graphConnection) GetAllSources(ctx context.Context) ([]graphModels.AnthroveSource, error) {
|
||||
return graph.GetAllSourceNodes(ctx, g.driver)
|
||||
}
|
||||
|
||||
func (g *graphConnection) GetSourceByURL(ctx context.Context, sourceUrl string) (*models.AnthroveSource, error) {
|
||||
func (g *graphConnection) GetSourceByURL(ctx context.Context, sourceUrl string) (*graphModels.AnthroveSource, error) {
|
||||
return graph.GetSourceNodesByURL(ctx, g.driver, sourceUrl)
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/internal/postgres"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
|
||||
gormPostgres "gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@ -35,27 +36,27 @@ func (p postgresqlConnection) AddUserWithRelationToSource(ctx context.Context, a
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) AddSource(ctx context.Context, anthroveSource *models.AnthroveSource) error {
|
||||
func (p postgresqlConnection) AddSource(ctx context.Context, anthroveSource *graphModels.AnthroveSource) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) AddPost(ctx context.Context, anthrovePost *models.AnthrovePost) error {
|
||||
func (p postgresqlConnection) AddPost(ctx context.Context, anthrovePost *graphModels.AnthrovePost) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.AnthroveTag) error {
|
||||
func (p postgresqlConnection) AddTagWithRelationToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *graphModels.AnthroveTag) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *models.AnthrovePostRelationship) error {
|
||||
func (p postgresqlConnection) LinkPostWithSource(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveSourceDomain string, anthrovePostRelationship *graphModels.AnthrovePostRelationship) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) LinkUserWithPost(ctx context.Context, anthroveUser *models.AnthroveUser, anthrovePost *models.AnthrovePost) error {
|
||||
func (p postgresqlConnection) LinkUserWithPost(ctx context.Context, anthroveUser *graphModels.AnthroveUser, anthrovePost *graphModels.AnthrovePost) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
@ -65,17 +66,17 @@ func (p postgresqlConnection) CheckUserPostLink(ctx context.Context, anthroveUse
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *models.AnthrovePost) (*models.AnthrovePost, bool, error) {
|
||||
func (p postgresqlConnection) CheckPostNodeExistsByAnthroveID(ctx context.Context, anthrovePost *graphModels.AnthrovePost) (*graphModels.AnthrovePost, bool, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*models.AnthrovePost, bool, error) {
|
||||
func (p postgresqlConnection) CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*graphModels.AnthrovePost, bool, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*models.AnthrovePost, bool, error) {
|
||||
func (p postgresqlConnection) CheckPostNodeExistsBySourceID(ctx context.Context, sourcePostID string) (*graphModels.AnthrovePost, bool, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
@ -85,17 +86,17 @@ func (p postgresqlConnection) GetUserFavoriteCount(ctx context.Context, anthrove
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.AnthroveUserRelationship, error) {
|
||||
func (p postgresqlConnection) GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]graphModels.AnthroveUserRelationship, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]models.AnthroveUserRelationship, error) {
|
||||
func (p postgresqlConnection) GetSpecifiedUserSourceLink(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceDisplayName string) (map[string]graphModels.AnthroveUserRelationship, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*models.AnthroveUser, error) {
|
||||
func (p postgresqlConnection) GetAnthroveUser(ctx context.Context, anthroveUserID models.AnthroveUserID) (*graphModels.AnthroveUser, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
@ -105,26 +106,26 @@ func (p postgresqlConnection) GetAllAnthroveUserIDs(ctx context.Context) ([]mode
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) GetUserFavoritePostsWithPagination(ctx context.Context, anthroveUserID models.AnthroveUserID, skip int, limit int) (*models.FavoriteList, error) {
|
||||
func (p postgresqlConnection) GetUserFavoritePostsWithPagination(ctx context.Context, anthroveUserID models.AnthroveUserID, skip int, limit int) (*graphModels.FavoriteList, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) GetUserTagsTroughFavedPosts(ctx context.Context, anthroveUserID models.AnthroveUserID) ([]models.TagsWithFrequency, error) {
|
||||
func (p postgresqlConnection) GetUserTagsTroughFavedPosts(ctx context.Context, anthroveUserID models.AnthroveUserID) ([]graphModels.TagsWithFrequency, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) GetAllTags(ctx context.Context) ([]models.TagsWithFrequency, error) {
|
||||
func (p postgresqlConnection) GetAllTags(ctx context.Context) ([]graphModels.TagsWithFrequency, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) GetAllSources(ctx context.Context) ([]models.AnthroveSource, error) {
|
||||
func (p postgresqlConnection) GetAllSources(ctx context.Context) ([]graphModels.AnthroveSource, error) {
|
||||
return postgres.GetAllSourceNodes(ctx, p.db)
|
||||
}
|
||||
|
||||
func (p postgresqlConnection) GetSourceByURL(ctx context.Context, sourceUrl string) (*models.AnthroveSource, error) {
|
||||
func (p postgresqlConnection) GetSourceByURL(ctx context.Context, sourceUrl string) (*graphModels.AnthroveSource, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
87
pkg/models/README.md
Normal file
87
pkg/models/README.md
Normal file
@ -0,0 +1,87 @@
|
||||
# Postgres
|
||||
|
||||
https://www.dbdiagram.io/d
|
||||
|
||||
````
|
||||
Table User {
|
||||
id string [primary key]
|
||||
created_at timestamp
|
||||
}
|
||||
|
||||
Table Post {
|
||||
id varchar(25) [primary key]
|
||||
rating Rating
|
||||
body text [note: 'Content of the post']
|
||||
user_id integer
|
||||
status post_status
|
||||
created_at timestamp
|
||||
}
|
||||
|
||||
Enum Rating {
|
||||
safe
|
||||
questionable
|
||||
explicit
|
||||
}
|
||||
|
||||
Table Source {
|
||||
id varchar(25) [primary key]
|
||||
display_name text
|
||||
domain text [not null, unique]
|
||||
}
|
||||
|
||||
Table Tag {
|
||||
name text [primary key]
|
||||
type TagType
|
||||
}
|
||||
|
||||
Enum TagType {
|
||||
general
|
||||
species
|
||||
character
|
||||
artist
|
||||
lore
|
||||
meta
|
||||
invalid
|
||||
}
|
||||
|
||||
Table TagAlias {
|
||||
name text [primary key]
|
||||
tag_id text
|
||||
}
|
||||
|
||||
Table TagGroup {
|
||||
name text [primary key]
|
||||
tag_id text
|
||||
}
|
||||
|
||||
Table UserFavorites {
|
||||
user_id text [primary key]
|
||||
post_id text [primary key]
|
||||
created_at timestamp
|
||||
}
|
||||
|
||||
Table UserSource {
|
||||
user_id text [primary key]
|
||||
source_id text [primary key]
|
||||
account_username text
|
||||
account_id text
|
||||
}
|
||||
|
||||
Table PostReference {
|
||||
post_id text [primary key]
|
||||
source_id text [primary key]
|
||||
url text [not null, unique]
|
||||
source_post_id text
|
||||
}
|
||||
|
||||
Ref: Tag.name > TagAlias.tag_id
|
||||
Ref: Tag.name > TagGroup.tag_id
|
||||
Ref: Tag.name <> Post.id
|
||||
Ref: UserFavorites.user_id > User.id
|
||||
Ref: UserFavorites.post_id > Post.id
|
||||
Ref: UserSource.user_id > User.id
|
||||
Ref: UserSource.source_id > Source.id
|
||||
Ref: PostReference.post_id > Post.id
|
||||
Ref: PostReference.source_id > Source.id
|
||||
|
||||
````
|
@ -2,16 +2,27 @@ package models
|
||||
|
||||
type AnthroveUserID string
|
||||
type AnthrovePostID string
|
||||
type AnthroveRating string
|
||||
type Rating string
|
||||
type TagType string
|
||||
|
||||
const (
|
||||
SFW AnthroveRating = "s"
|
||||
NSFW AnthroveRating = "e"
|
||||
Questionable AnthroveRating = "q"
|
||||
Unknown AnthroveRating = "unknown"
|
||||
SFW Rating = "s"
|
||||
NSFW Rating = "e"
|
||||
Questionable Rating = "q"
|
||||
Unknown Rating = "unknown"
|
||||
)
|
||||
|
||||
func (r *AnthroveRating) Convert(e621Rating string) {
|
||||
const (
|
||||
General TagType = "general"
|
||||
Species TagType = "species"
|
||||
Character TagType = "character"
|
||||
Artist TagType = "artist"
|
||||
Lore TagType = "lore"
|
||||
Meta TagType = "meta"
|
||||
Invalid TagType = "invalid"
|
||||
)
|
||||
|
||||
func (r *Rating) Convert(e621Rating string) {
|
||||
|
||||
switch e621Rating {
|
||||
case "e":
|
||||
|
@ -1,4 +1,4 @@
|
||||
package models
|
||||
package graphModels
|
||||
|
||||
type FavoriteRelations struct {
|
||||
SourcesID string `json:"sources_id"`
|
8
pkg/models/graphModels/post.go
Normal file
8
pkg/models/graphModels/post.go
Normal file
@ -0,0 +1,8 @@
|
||||
package graphModels
|
||||
|
||||
import "git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
|
||||
type AnthrovePost struct {
|
||||
PostID models.AnthrovePostID `json:"post_id"`
|
||||
Rating models.Rating `json:"rating"`
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package models
|
||||
package graphModels
|
||||
|
||||
type AnthroveUserRelationship struct {
|
||||
UserID string `json:"user_id"`
|
@ -1,4 +1,4 @@
|
||||
package models
|
||||
package graphModels
|
||||
|
||||
type AnthroveSource struct {
|
||||
DisplayName string `json:"display_name"`
|
@ -1,4 +1,4 @@
|
||||
package models
|
||||
package graphModels
|
||||
|
||||
type AnthroveTag struct {
|
||||
Name string `json:"name"`
|
8
pkg/models/graphModels/user.go
Normal file
8
pkg/models/graphModels/user.go
Normal file
@ -0,0 +1,8 @@
|
||||
package graphModels
|
||||
|
||||
import "git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
|
||||
type AnthroveUser struct {
|
||||
UserID models.AnthroveUserID `json:"user_id"`
|
||||
Relationship []AnthroveUserRelationship `json:"relationship"`
|
||||
}
|
13
pkg/models/pgModels/orm.go
Normal file
13
pkg/models/pgModels/orm.go
Normal file
@ -0,0 +1,13 @@
|
||||
package pgModels
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type BaseModel struct {
|
||||
ID string `gorm:"primaryKey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
}
|
14
pkg/models/pgModels/post.go
Normal file
14
pkg/models/pgModels/post.go
Normal file
@ -0,0 +1,14 @@
|
||||
package pgModels
|
||||
|
||||
import (
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
)
|
||||
|
||||
// Post model
|
||||
type Post struct {
|
||||
BaseModel
|
||||
Rating models.Rating `gorm:"type:rating"`
|
||||
Body string `gorm:"type:text"`
|
||||
UserID int `gorm:"index"`
|
||||
Status string `gorm:"type:post_status"`
|
||||
}
|
8
pkg/models/pgModels/source.go
Normal file
8
pkg/models/pgModels/source.go
Normal file
@ -0,0 +1,8 @@
|
||||
package pgModels
|
||||
|
||||
// Source model
|
||||
type Source struct {
|
||||
BaseModel
|
||||
DisplayName string `gorm:"type:text"`
|
||||
Domain string `gorm:"type:text;not null;unique"`
|
||||
}
|
21
pkg/models/pgModels/tag.go
Normal file
21
pkg/models/pgModels/tag.go
Normal file
@ -0,0 +1,21 @@
|
||||
package pgModels
|
||||
|
||||
import "git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
|
||||
// Tag models
|
||||
type Tag struct {
|
||||
Name string `gorm:"primaryKey"`
|
||||
Type models.TagType `gorm:"type:tag_type"`
|
||||
}
|
||||
|
||||
// TagAlias model
|
||||
type TagAlias struct {
|
||||
Name string `gorm:"primaryKey"`
|
||||
TagID string `gorm:"index"`
|
||||
}
|
||||
|
||||
// TagGroup model
|
||||
type TagGroup struct {
|
||||
Name string `gorm:"primaryKey"`
|
||||
TagID string `gorm:"index"`
|
||||
}
|
6
pkg/models/pgModels/user.go
Normal file
6
pkg/models/pgModels/user.go
Normal file
@ -0,0 +1,6 @@
|
||||
package pgModels
|
||||
|
||||
// User model
|
||||
type User struct {
|
||||
BaseModel
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package models
|
||||
|
||||
type AnthrovePost struct {
|
||||
PostID AnthrovePostID `json:"post_id"`
|
||||
Rating AnthroveRating `json:"rating"`
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package models
|
||||
|
||||
type AnthroveUser struct {
|
||||
UserID AnthroveUserID `json:"user_id"`
|
||||
Relationship []AnthroveUserRelationship `json:"relationship"`
|
||||
}
|
Reference in New Issue
Block a user