2024-12-14 08:35:45 +00:00
|
|
|
package taskservice
|
|
|
|
|
|
|
|
import (
|
2025-01-07 14:54:16 +00:00
|
|
|
"code.aides.space/aides-infra/aides-repo-api/internal/models"
|
2024-12-14 08:35:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Service) Create(repo string) (*models.Task, error) {
|
|
|
|
taskRepo := models.GitRepo{
|
|
|
|
Name: repo,
|
|
|
|
}
|
2024-12-15 09:03:11 +00:00
|
|
|
s.db.
|
2024-12-14 08:35:45 +00:00
|
|
|
Where(&taskRepo).
|
|
|
|
FirstOrCreate(&taskRepo)
|
|
|
|
|
|
|
|
altRepo := models.ALTRepo{
|
|
|
|
Name: "Sisyphus",
|
|
|
|
}
|
2024-12-15 06:16:51 +00:00
|
|
|
s.db.
|
2024-12-14 08:35:45 +00:00
|
|
|
Where(&altRepo).
|
|
|
|
FirstOrCreate(&altRepo)
|
|
|
|
|
|
|
|
task := models.Task{
|
2024-12-26 16:20:54 +00:00
|
|
|
Repo: &taskRepo,
|
2024-12-14 08:35:45 +00:00
|
|
|
ALTRepo: altRepo,
|
|
|
|
Type: models.TypeUpsert,
|
2024-12-26 13:42:54 +00:00
|
|
|
Status: models.StatusPending,
|
2024-12-14 08:35:45 +00:00
|
|
|
}
|
|
|
|
|
2024-12-15 06:16:51 +00:00
|
|
|
result := s.db.Create(&task)
|
2024-12-14 08:35:45 +00:00
|
|
|
|
|
|
|
return &task, result.Error
|
|
|
|
}
|