nidus-sync/db/query/comms/text_job.go
Eli Ribble 7237f5f666
Some checks failed
/ golint (push) Failing after 3m50s
Move internal references to new source hosting
2026-05-19 15:33:57 +00:00

42 lines
1.5 KiB
Go

package comms
import (
"context"
"github.com/Gleipnir-Technology/jet/postgres"
"source.gleipnir.technology/Gleipnir/nidus-sync/db"
"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/comms/model"
"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/comms/table"
)
func TextJobComplete(ctx context.Context, txn db.Ex, id int64) error {
statement := table.TextJob.UPDATE(
table.TextJob.Completed,
).SET(
table.TextJob.Completed.SET(postgres.LOCALTIMESTAMP()),
).WHERE(
table.TextJob.ID.EQ(postgres.Int(id)),
)
return db.ExecuteNoneTx(ctx, txn, statement)
}
func TextJobFromID(ctx context.Context, txn db.Ex, id int64) (model.TextJob, error) {
statement := table.TextJob.SELECT(
table.TextJob.AllColumns,
).FROM(table.TextJob).
WHERE(table.TextJob.ID.EQ(postgres.Int(id)))
return db.ExecuteOneTx[model.TextJob](ctx, txn, statement)
}
func TextJobInsert(ctx context.Context, txn db.Ex, m model.TextJob) (model.TextJob, error) {
statement := table.TextJob.INSERT(
table.TextJob.MutableColumns,
).MODEL(m)
return db.ExecuteOneTx[model.TextJob](ctx, txn, statement)
}
func TextJobsWaitingFromDestination(ctx context.Context, txn db.Ex, destination string) ([]model.TextJob, error) {
statement := table.TextJob.SELECT(
table.TextJob.AllColumns,
).FROM(table.TextJob).
WHERE(table.TextJob.Destination.EQ(postgres.String(destination)).AND(
table.TextJob.Completed.IS_NULL()))
return db.ExecuteManyTx[model.TextJob](ctx, txn, statement)
}