aides-repo-api/internal/services/taskservice/create.go
Maxim Slipenko e4f9743dea
Some checks failed
Format and Lint / format-check (push) Failing after 2s
Format and Lint / test (push) Successful in 52s
chore: change code.alt-gnome to code.aides.space
2025-01-07 17:54:16 +03:00

32 lines
555 B
Go

package taskservice
import (
"code.aides.space/aides-infra/aides-repo-api/internal/models"
)
func (s *Service) Create(repo string) (*models.Task, error) {
taskRepo := models.GitRepo{
Name: repo,
}
s.db.
Where(&taskRepo).
FirstOrCreate(&taskRepo)
altRepo := models.ALTRepo{
Name: "Sisyphus",
}
s.db.
Where(&altRepo).
FirstOrCreate(&altRepo)
task := models.Task{
Repo: &taskRepo,
ALTRepo: altRepo,
Type: models.TypeUpsert,
Status: models.StatusPending,
}
result := s.db.Create(&task)
return &task, result.Error
}