feat: upload Posts in batch (no tests)

This commit is contained in:
SoXX 2024-07-03 22:57:04 +02:00
parent 509abb0f75
commit 419099a0de
2 changed files with 8 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package database
import ( import (
"context" "context"
"gorm.io/gorm"
"git.dragse.it/anthrove/otter-space-sdk/v2/pkg/models" "git.dragse.it/anthrove/otter-space-sdk/v2/pkg/models"
) )
@ -11,6 +12,9 @@ type Post interface {
// CreatePost adds a new post to the database. // CreatePost adds a new post to the database.
CreatePost(ctx context.Context, anthrovePost *models.Post) error CreatePost(ctx context.Context, anthrovePost *models.Post) error
// TODO: Everything
CreatePostInBatch(ctx context.Context, db *gorm.DB, anthrovePost []models.Post, batchSize int) error
// GetPostByAnthroveID retrieves a post by its Anthrove ID. // GetPostByAnthroveID retrieves a post by its Anthrove ID.
GetPostByAnthroveID(ctx context.Context, anthrovePostID models.AnthrovePostID) (*models.Post, error) GetPostByAnthroveID(ctx context.Context, anthrovePostID models.AnthrovePostID) (*models.Post, error)

View File

@ -92,6 +92,10 @@ func (p *postgresqlConnection) CreatePost(ctx context.Context, anthrovePost *mod
return postgres.CreatePost(ctx, p.db, anthrovePost) return postgres.CreatePost(ctx, p.db, anthrovePost)
} }
func (p *postgresqlConnection) CreatePostInBatch(ctx context.Context, db *gorm.DB, anthrovePost []models.Post, batchSize int) error {
return postgres.CreatePostInBatch(ctx, p.db, anthrovePost, batchSize)
}
func (p *postgresqlConnection) CreatePostWithReferenceToTagAnd(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.Tag) error { func (p *postgresqlConnection) CreatePostWithReferenceToTagAnd(ctx context.Context, anthrovePostID models.AnthrovePostID, anthroveTag *models.Tag) error {
return postgres.CreateTagAndReferenceToPost(ctx, p.db, anthrovePostID, anthroveTag) return postgres.CreateTagAndReferenceToPost(ctx, p.db, anthrovePostID, anthroveTag)
} }