scanfile/server/internal/database/processingJob.go
2025-06-03 15:44:56 +02:00

38 lines
798 B
Go

package database
import (
"log/slog"
"time"
)
type ProcessingJob struct {
Id int64
FileID int64
FileUUID string
Created time.Time `xorm:"created"`
Started time.Time
Completed time.Time
Status string //Could be an enum, but who cares
Type string
}
func (j ProcessingJob) Update() error {
_, err := engine.Update(j)
if err != nil {
slog.Error("Error updating processing job", "error", err, "file-uuid", j.FileUUID, "job-id", j.Id, "job-type", j.Type)
}
return err
}
func NewProcessingJob(fileID int64, fileUUID string) (ProcessingJob, error) {
job := ProcessingJob{
FileID: fileID,
}
_, err := engine.InsertOne(job)
if err != nil {
slog.Error("Unable to create new processing job", "file-uuid", fileUUID)
return job, err
}
return job, nil
}