v.0.0.3.1 Добавлено логирование создания клипа
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
272c76909b
commit
b954bc5cc6
@ -36,6 +36,15 @@ func NewClipRepository(db *sql.DB) ClipRepository {
|
||||
}
|
||||
|
||||
func (r *clipRepository) Create(ctx context.Context, clip *domain.Clip) error {
|
||||
if clip.VideoURL == "" {
|
||||
return fmt.Errorf("VideoURL cannot be empty")
|
||||
}
|
||||
if clip.ThumbnailURL == "" {
|
||||
return fmt.Errorf("ThumbnailURL cannot be empty")
|
||||
}
|
||||
if clip.AuthorID == 0 {
|
||||
return fmt.Errorf("AuthorID cannot be 0")
|
||||
}
|
||||
query := `
|
||||
INSERT INTO clips (title, video_url, thumbnail_url, author_id, likes_count, comments_count, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
|
||||
@ -42,7 +42,7 @@ func NewClipService(repo repository.ClipRepository, storage storage.Storage, pro
|
||||
|
||||
func (s *clipService) CreateClip(ctx context.Context, req domain.CreateClipRequest) (*domain.Clip, error) {
|
||||
const op = "service/clipService.CreateClip"
|
||||
|
||||
log.Printf("%s: starting clip creation for user %d", op, req.UserID)
|
||||
// 1. Параллельно обрабатываем видео и генерируем превью
|
||||
trimmedVideoChan := make(chan []byte, 1)
|
||||
trimmedErrChan := make(chan error, 1)
|
||||
@ -131,7 +131,18 @@ func (s *clipService) CreateClip(ctx context.Context, req domain.CreateClipReque
|
||||
s.storage.DeleteThumbnail(ctx, thumbnailURL)
|
||||
return nil, fmt.Errorf("failed to create clip: %w", err)
|
||||
}
|
||||
log.Printf("%s: clip created successfully, ID: %d", op, clip.ID)
|
||||
|
||||
// Проверяем что все поля заполнены
|
||||
if clip.VideoURL == "" {
|
||||
log.Printf("%s: WARNING - VideoURL is empty", op)
|
||||
}
|
||||
if clip.ThumbnailURL == "" {
|
||||
log.Printf("%s: WARNING - ThumbnailURL is empty", op)
|
||||
}
|
||||
if clip.AuthorID == 0 {
|
||||
log.Printf("%s: WARNING - AuthorID is 0", op)
|
||||
}
|
||||
return clip, nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user