develop/batch-jobs #13

Merged
fenpaws merged 11 commits from develop/batch-jobs into main 2024-07-06 21:49:26 +00:00
Showing only changes of commit ad9124ef41 - Show all commits

View File

@ -3,6 +3,7 @@ package postgres
import ( import (
"context" "context"
"errors" "errors"
otterError "git.dragse.it/anthrove/otter-space-sdk/v2/pkg/error" otterError "git.dragse.it/anthrove/otter-space-sdk/v2/pkg/error"
"git.dragse.it/anthrove/otter-space-sdk/v2/pkg/models" "git.dragse.it/anthrove/otter-space-sdk/v2/pkg/models"
@ -38,14 +39,14 @@ func CreatePost(ctx context.Context, db *gorm.DB, anthrovePost *models.Post) err
// TODO: Make Tests // TODO: Make Tests
func CreatePostInBatch(ctx context.Context, db *gorm.DB, anthrovePost []models.Post, batchSize int) error { func CreatePostInBatch(ctx context.Context, db *gorm.DB, anthrovePost []models.Post, batchSize int) error {
if len(anthrovePost) == 0 {
return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be empty"}
}
if anthrovePost == nil { if anthrovePost == nil {
return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be nil"} return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be nil"}
} }
if len(anthrovePost) == 0 {
return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be empty"}
}
if batchSize == 0 { if batchSize == 0 {
return &otterError.EntityValidationFailed{Reason: "batch size cannot be zero"} return &otterError.EntityValidationFailed{Reason: "batch size cannot be zero"}
} }