CI / ci (push) Successful in 8m28s
Co-authored-by: dev_agent <dev_agent@cubecraftlabs.com>
39 lines
874 B
Go
39 lines
874 B
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: schedule_runs.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const claimScheduleRun = `-- name: ClaimScheduleRun :execrows
|
|
INSERT INTO schedule_runs (id, schedule, period_key, created_at)
|
|
VALUES (?, ?, ?, ?)
|
|
ON CONFLICT (schedule, period_key) DO NOTHING
|
|
`
|
|
|
|
type ClaimScheduleRunParams struct {
|
|
ID string
|
|
Schedule string
|
|
PeriodKey string
|
|
CreatedAt string
|
|
}
|
|
|
|
// Claims one period of a schedule. The insert is the claim: 1 row means
|
|
// this caller owns the period, 0 rows means it was already claimed.
|
|
func (q *Queries) ClaimScheduleRun(ctx context.Context, arg ClaimScheduleRunParams) (int64, error) {
|
|
result, err := q.db.ExecContext(ctx, claimScheduleRun,
|
|
arg.ID,
|
|
arg.Schedule,
|
|
arg.PeriodKey,
|
|
arg.CreatedAt,
|
|
)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected()
|
|
}
|