fix
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"control/analize"
|
||||
"github.com/gocarina/gocsv"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -26,11 +25,13 @@ func exists(path string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
const BASE_DIR = "./data"
|
||||
|
||||
func worker(id int, jobs <-chan ControlCase, ctx context.Context, db *gorm.DB) {
|
||||
for j := range jobs {
|
||||
fmt.Printf("Worker %d started job %d \n", id, j.ID)
|
||||
p := j.Params
|
||||
p.FolderPath = filepath.Join(".", fmt.Sprintf("%d", p.ID))
|
||||
p.FolderPath = filepath.Join(BASE_DIR, fmt.Sprintf("%d", p.ID))
|
||||
|
||||
exists, err := p.Exist()
|
||||
if err != nil {
|
||||
@@ -49,12 +50,6 @@ func worker(id int, jobs <-chan ControlCase, ctx context.Context, db *gorm.DB) {
|
||||
}
|
||||
}
|
||||
|
||||
csvPath := filepath.Join(p.FolderPath, "foo.csv")
|
||||
if _, err := analize.AnalyzeCSV(db, j.ID, j.Name, csvPath); err != nil {
|
||||
fmt.Printf("Worker %d failed to analyze job %d: %v\n", id, j.ID, err)
|
||||
continue
|
||||
}
|
||||
|
||||
j.Status = "R"
|
||||
if err := db.Model(&ControlCase{}).Where("id = ?", j.ID).Update("status", j.Status).Error; err != nil {
|
||||
fmt.Printf("Worker %d failed to update status for job %d: %v\n", id, j.ID, err)
|
||||
@@ -92,6 +87,7 @@ func readFromDb(db *gorm.DB) []ControlCase {
|
||||
_ = db.
|
||||
Where("status IN ?", statuses).
|
||||
Preload("Params").
|
||||
Preload("Params.InitialCondition").
|
||||
Find(&cases).Error
|
||||
return cases
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user