2024-06-03 17:31:25 +00:00
|
|
|
package database
|
2024-02-16 14:16:50 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-06-24 10:59:51 +00:00
|
|
|
|
2024-02-16 20:51:09 +00:00
|
|
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
2024-02-16 14:16:50 +00:00
|
|
|
)
|
|
|
|
|
2024-02-16 20:57:54 +00:00
|
|
|
type OtterSpace interface {
|
2024-06-22 21:23:23 +00:00
|
|
|
// Connect establishes a connection to the database.
|
2024-06-24 10:59:51 +00:00
|
|
|
Connect(ctx context.Context, config models.DatabaseConfig) error
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// CreateUserWithRelationToSource adds a user with a relation to a source.
|
2024-06-23 20:35:46 +00:00
|
|
|
CreateUserWithRelationToSource(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceID models.AnthroveSourceID, accountId string, accountUsername string) error
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// CreateSource adds a new source to the database.
|
|
|
|
CreateSource(ctx context.Context, anthroveSource *models.Source) error
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// CreatePost adds a new post to the database.
|
|
|
|
CreatePost(ctx context.Context, anthrovePost *models.Post) error
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// CreateTagAndReferenceToPost adds a tag with a relation to a post.
|
|
|
|
CreateTagAndReferenceToPost(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.Tag) error
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// CreateReferenceBetweenPostAndSource links a post with a source.
|
2024-06-26 14:12:10 +00:00
|
|
|
CreateReferenceBetweenPostAndSource(ctx context.Context, anthrovePostID models.AnthrovePostID, sourceDomain models.AnthroveSourceDomain, postURL models.AnthrovePostURL) error
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// CreateReferenceBetweenUserAndPost links a user with a post.
|
2024-06-23 20:39:54 +00:00
|
|
|
CreateReferenceBetweenUserAndPost(ctx context.Context, anthroveUserID models.AnthroveUserID, anthrovePostID models.AnthrovePostID) error
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// CheckReferenceBetweenUserAndPost checks if a user-post link exists.
|
2024-06-23 20:35:46 +00:00
|
|
|
CheckReferenceBetweenUserAndPost(ctx context.Context, anthroveUserID models.AnthroveUserID, sourcePostID models.AnthrovePostID) (bool, error)
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-22 21:23:23 +00:00
|
|
|
// GetPostByAnthroveID retrieves a post by its Anthrove ID.
|
2024-06-24 20:07:34 +00:00
|
|
|
GetPostByAnthroveID(ctx context.Context, anthrovePostID models.AnthrovePostID) (*models.Post, error)
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 20:35:46 +00:00
|
|
|
// GetPostByURL retrieves a post by its source URL.
|
|
|
|
GetPostByURL(ctx context.Context, sourceUrl string) (*models.Post, error)
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-22 21:23:23 +00:00
|
|
|
// GetPostBySourceID retrieves a post by its source ID.
|
2024-06-23 20:35:46 +00:00
|
|
|
GetPostBySourceID(ctx context.Context, sourceID models.AnthroveSourceID) (*models.Post, error)
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// GetUserFavoritesCount retrieves the count of a user's favorites.
|
|
|
|
GetUserFavoritesCount(ctx context.Context, anthroveUserID models.AnthroveUserID) (int64, error)
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-22 21:23:23 +00:00
|
|
|
// GetUserSourceLinks retrieves the source links of a user.
|
2024-06-22 20:06:36 +00:00
|
|
|
GetUserSourceLinks(ctx context.Context, anthroveUserID models.AnthroveUserID) (map[string]models.UserSource, error)
|
2024-02-16 14:16:50 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// GetUserSourceBySourceID retrieves a specified source link of a user.
|
2024-06-23 20:35:46 +00:00
|
|
|
GetUserSourceBySourceID(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceID models.AnthroveSourceID) (map[string]models.UserSource, error)
|
2024-05-04 22:17:18 +00:00
|
|
|
|
2024-06-22 21:23:23 +00:00
|
|
|
// GetAllAnthroveUserIDs retrieves all Anthrove user IDs.
|
2024-02-16 14:16:50 +00:00
|
|
|
GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error)
|
2024-05-10 08:57:51 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// GetUserFavoriteWithPagination retrieves a user's favorite posts with pagination.
|
|
|
|
GetUserFavoriteWithPagination(ctx context.Context, anthroveUserID models.AnthroveUserID, skip int, limit int) (*models.FavoriteList, error)
|
2024-05-15 13:18:23 +00:00
|
|
|
|
2024-06-23 19:23:38 +00:00
|
|
|
// GetUserTagWitRelationToFavedPosts retrieves a user's tags through their favorited posts.
|
|
|
|
GetUserTagWitRelationToFavedPosts(ctx context.Context, anthroveUserID models.AnthroveUserID) ([]models.TagsWithFrequency, error)
|
2024-05-15 13:31:17 +00:00
|
|
|
|
2024-06-22 21:23:23 +00:00
|
|
|
// GetAllTags retrieves all tags.
|
2024-06-23 19:23:38 +00:00
|
|
|
GetAllTags(ctx context.Context) ([]models.Tag, error)
|
2024-05-15 13:44:34 +00:00
|
|
|
|
2024-06-22 21:23:23 +00:00
|
|
|
// GetAllSources retrieves all sources.
|
2024-06-22 20:06:36 +00:00
|
|
|
GetAllSources(ctx context.Context) ([]models.Source, error)
|
2024-05-21 09:48:03 +00:00
|
|
|
|
2024-06-23 20:35:46 +00:00
|
|
|
// GetSourceByDomain retrieves a source by its URL.
|
|
|
|
GetSourceByDomain(ctx context.Context, sourceDomain models.AnthroveSourceDomain) (*models.Source, error)
|
2024-02-16 14:16:50 +00:00
|
|
|
}
|