32 lines
555 B
Go
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
|
|
}
|