Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/handler/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ type updateTaskIn struct {
WatcherUsernames []string `json:"watcher_usernames"`
WatcherGroups []string `json:"watcher_groups"`
Tags map[string]string `json:"tags"`
DueDateAt *time.Time `json:"due_date_at"`
}

// UpdateTask modifies a task, allowing it's requester or an administrator
Expand Down Expand Up @@ -324,6 +325,7 @@ func UpdateTask(c *gin.Context, in *updateTaskIn) (*task.Task, error) {
t.SetInput(clearInput)
t.SetWatcherUsernames(in.WatcherUsernames)
t.SetWatcherGroups(in.WatcherGroups)
t.SetDueDateAt(in.DueDateAt)

// validate read-only tags
v, readOnlyTagUpdated := in.Tags[constants.SubtaskTagParentTaskID]
Expand Down
9 changes: 8 additions & 1 deletion models/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type DBModel struct {
StepsTotal int `json:"steps_total" db:"steps_total"`
LastActivity time.Time `json:"last_activity" db:"last_activity"`
Tags map[string]string `json:"tags,omitempty" db:"tags"`
DueDateAt *time.Time `json:"due_date_at,omitempty" db:"due_date_at"`

CryptKey []byte `json:"-" db:"crypt_key"` // key for encrypting steps (itself encrypted with master key)
EncryptedInput []byte `json:"-" db:"encrypted_input"`
Expand Down Expand Up @@ -574,6 +575,12 @@ func (t *Task) SetWatcherGroups(watcherGroups []string) {
t.WatcherGroups = watcherGroups
}

// SetDueDateAt sets the due date for the task
// Pass nil to clear the due date
func (t *Task) SetDueDateAt(dueDateAt *time.Time) {
t.DueDateAt = dueDateAt
}

// SetInput sets the provided input for the task
func (t *Task) SetInput(input map[string]interface{}) {
t.Input = input
Expand Down Expand Up @@ -692,7 +699,7 @@ func (t *Task) ExportTaskInfos(values *values.Values) {

var (
tSelector = sqlgenerator.PGsql.Select(
`"task".id, "task".public_id, "task".title, "task".id_template, "task".id_batch, "task".requester_username, "task".requester_groups, "task".watcher_usernames, "task".watcher_groups, "task".created, "task".state, "task".tags, "task".steps_done, "task".steps_total, "task".crypt_key, "task".encrypted_input, "task".encrypted_result, "task".last_activity, "task".resolver_usernames, "task".resolver_groups, "task_template".name as template_name, "task_template".resolver_inputs as resolver_inputs, "resolution".public_id as resolution_public_id, "resolution".last_start as last_start, "resolution".last_stop as last_stop, "resolution".resolver_username as resolver_username, "batch".public_id as batch_public_id`,
`"task".id, "task".public_id, "task".title, "task".id_template, "task".id_batch, "task".requester_username, "task".requester_groups, "task".watcher_usernames, "task".watcher_groups, "task".created, "task".state, "task".tags, "task".steps_done, "task".steps_total, "task".crypt_key, "task".encrypted_input, "task".encrypted_result, "task".last_activity, "task".resolver_usernames, "task".resolver_groups, "task".due_date_at, "task_template".name as template_name, "task_template".resolver_inputs as resolver_inputs, "resolution".public_id as resolution_public_id, "resolution".last_start as last_start, "resolution".last_stop as last_stop, "resolution".resolver_username as resolver_username, "batch".public_id as batch_public_id`,
).From(
`"task"`,
).Join(
Expand Down
4 changes: 4 additions & 0 deletions sql/migrations/011_task_due_date.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Migration: Add due_date_at column to task table
-- Allows tasks to have an optional deadline

ALTER TABLE "task" ADD COLUMN IF NOT EXISTS due_date_at TIMESTAMP with time zone;
3 changes: 2 additions & 1 deletion sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ CREATE TABLE "task" (
crypt_key BYTEA NOT NULL,
encrypted_input BYTEA NOT NULL,
encrypted_result BYTEA NOT NULL,
tags JSONB NOT NULL DEFAULT 'null'
tags JSONB NOT NULL DEFAULT 'null',
due_date_at TIMESTAMP with time zone
);

CREATE INDEX ON "task"(id_template);
Expand Down