refactor: creating image process to handle processing of images
Decoupling this from the DB, it's a good step. Not yet perfect however.
This commit is contained in:
@@ -160,6 +160,28 @@ func (m ImageModel) FinishProcessing(ctx context.Context, imageId uuid.UUID) (mo
|
||||
return userImage, err
|
||||
}
|
||||
|
||||
func (m ImageModel) GetImageToProcessID(ctx context.Context, imageID uuid.UUID) (uuid.UUID, error) {
|
||||
getImageToProcessIDStmt := UserImagesToProcess.
|
||||
SELECT(UserImagesToProcess.ID).
|
||||
WHERE(UserImagesToProcess.ImageID.EQ(UUID(imageID)))
|
||||
|
||||
imageToProcess := model.UserImagesToProcess{}
|
||||
err := getImageToProcessIDStmt.QueryContext(ctx, m.dbPool, &imageToProcess)
|
||||
|
||||
return imageToProcess.ID, err
|
||||
}
|
||||
|
||||
func (m ImageModel) SetNotStarted(ctx context.Context, processingImageId uuid.UUID) error {
|
||||
startProcessingStmt := UserImagesToProcess.
|
||||
UPDATE(UserImagesToProcess.Status).
|
||||
SET(model.Progress_NotStarted).
|
||||
WHERE(UserImagesToProcess.ID.EQ(UUID(processingImageId)))
|
||||
|
||||
_, err := startProcessingStmt.ExecContext(ctx, m.dbPool)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (m ImageModel) StartProcessing(ctx context.Context, processingImageId uuid.UUID) error {
|
||||
startProcessingStmt := UserImagesToProcess.
|
||||
UPDATE(UserImagesToProcess.Status).
|
||||
|
||||
Reference in New Issue
Block a user