WIP: convert GORM to sqlc, for jobs/tasks #104304
@ -589,10 +589,17 @@ func (db *DB) SaveTaskStatus(ctx context.Context, t *Task) error {
|
||||
}
|
||||
|
||||
func (db *DB) SaveTaskActivity(ctx context.Context, t *Task) error {
|
||||
if err := db.gormDB.WithContext(ctx).
|
||||
Model(t).
|
||||
Select("Activity").
|
||||
Updates(Task{Activity: t.Activity}).Error; err != nil {
|
||||
queries, err := db.queries()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = queries.UpdateTaskActivity(ctx, sqlc.UpdateTaskActivityParams{
|
||||
UpdatedAt: db.now(),
|
||||
Activity: t.Activity,
|
||||
ID: int64(t.ID),
|
||||
})
|
||||
if err != nil {
|
||||
return taskError(err, "saving task activity")
|
||||
}
|
||||
return nil
|
||||
|
@ -94,3 +94,9 @@ UPDATE tasks SET
|
||||
updated_at = @updated_at,
|
||||
status = @status
|
||||
WHERE id=@id;
|
||||
|
||||
-- name: UpdateTaskActivity :exec
|
||||
UPDATE tasks SET
|
||||
updated_at = @updated_at,
|
||||
activity = @activity
|
||||
WHERE id=@id;
|
||||
|
@ -424,6 +424,24 @@ func (q *Queries) UpdateTask(ctx context.Context, arg UpdateTaskParams) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const updateTaskActivity = `-- name: UpdateTaskActivity :exec
|
||||
UPDATE tasks SET
|
||||
updated_at = ?1,
|
||||
activity = ?2
|
||||
WHERE id=?3
|
||||
`
|
||||
|
||||
type UpdateTaskActivityParams struct {
|
||||
UpdatedAt sql.NullTime
|
||||
Activity string
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTaskActivity(ctx context.Context, arg UpdateTaskActivityParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateTaskActivity, arg.UpdatedAt, arg.Activity, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateTaskStatus = `-- name: UpdateTaskStatus :exec
|
||||
UPDATE tasks SET
|
||||
updated_at = ?1,
|
||||
|
Loading…
Reference in New Issue
Block a user