~comcloudway/builds.sr.ht

20aaddd4ef1b2d2d9052c15a1d4052c80f8260f1 — Simon Ser 1 year, 2 months ago a17bcc9
api/graph: simplify status for new jobs

The status is always "pending". Mimick what the "INSERT INTO task"
query is doing below.
1 files changed, 2 insertions(+), 6 deletions(-)

M api/graph/schema.resolvers.go
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +2 -6
@@ 301,10 301,6 @@ func (r *mutationResolver) Submit(ctx context.Context, manifest string, tags []s

	var job model.Job
	if err := database.WithTx(ctx, nil, func(tx *sql.Tx) error {
		status := "pending"
		if execute == nil || *execute {
			status = "pending"
		}
		tags := strings.Join(tags, "/")

		// TODO: Refactor tags into a pg array


@@ 314,11 310,11 @@ func (r *mutationResolver) Submit(ctx context.Context, manifest string, tags []s
		) VALUES (
			NOW() at time zone 'utc',
			NOW() at time zone 'utc',
			$1, $2, $3, $4, $5, $6, $7, $8
			$1, $2, $3, $4, $5, $6, 'pending', $7
		) RETURNING
			id, created, updated, manifest, note, image, runner, owner_id,
			tags, status, visibility
		`, manifest, user.UserID, sec, note, tags, man.Image, status, vis)
		`, manifest, user.UserID, sec, note, tags, man.Image, vis)

		if err := row.Scan(&job.ID, &job.Created, &job.Updated, &job.Manifest,
			&job.Note, &job.Image, &job.Runner, &job.OwnerID, &job.RawTags,