Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tasks): add description field to tasks #13850

Merged
merged 1 commit into from
May 9, 2019
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## v2.0.0-alpha.10 [unreleased]

### Features

1. [13850](https://github.com/influxdata/influxdb/pull/13850): Add description field to Tasks.

### Bug Fixes

1. [13753](https://github.com/influxdata/influxdb/pull/13753): Removed hardcoded bucket for Getting Started with Flux dashboard
1. [13783](https://github.com/influxdata/influxdb/pull/13783): Ensure map type variables allow for selecting values
1. [13800](https://github.com/influxdata/influxdb/pull/13800): Generate more idiomatic Flux in query builder
Expand Down
5 changes: 4 additions & 1 deletion http/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5840,7 +5840,10 @@ components:
description: The name of the organization that owns this Task.
type: string
name:
description: A description of the task.
description: The name of the task.
type: string
description:
descripton: An optional description of the task.
type: string
status:
description: The current status of the task. When updated to 'inactive', cancels all queued jobs of this task.
Expand Down
6 changes: 5 additions & 1 deletion http/task_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func TestTaskHandler_handleGetTasks(t *testing.T) {
{
ID: 1,
Name: "task1",
Description: "A little Task",
OrganizationID: 1,
Organization: "test",
AuthorizationID: 0x100,
Expand Down Expand Up @@ -137,7 +138,8 @@ func TestTaskHandler_handleGetTasks(t *testing.T) {
},
"id": "0000000000000001",
"name": "task1",
"labels": [
"description": "A little Task",
"labels": [
{
"id": "fc3dc670a4be9b9a",
"name": "label",
Expand Down Expand Up @@ -449,6 +451,7 @@ func TestTaskHandler_handlePostTasks(t *testing.T) {
return &platform.Task{
ID: 1,
Name: "task1",
Description: "Brand New Task",
OrganizationID: 1,
Organization: "test",
AuthorizationID: 0x100,
Expand All @@ -472,6 +475,7 @@ func TestTaskHandler_handlePostTasks(t *testing.T) {
},
"id": "0000000000000001",
"name": "task1",
"description": "Brand New Task",
"labels": [],
"orgID": "0000000000000001",
"org": "test",
Expand Down
5 changes: 5 additions & 0 deletions kv/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ func (s *Service) createTask(ctx context.Context, tx Tx, tc influxdb.TaskCreate)
Organization: org.Name,
AuthorizationID: auth.Identifier(),
Name: opt.Name,
Description: tc.Description,
Status: tc.Status,
Flux: tc.Flux,
Every: opt.Every.String(),
Expand Down Expand Up @@ -677,6 +678,10 @@ func (s *Service) updateTask(ctx context.Context, tx Tx, id influxdb.ID, upd inf
task.AuthorizationID = auth.ID
}

if upd.Description != nil {
task.Description = *upd.Description
}

if upd.Status != nil {
task.Status = *upd.Status
}
Expand Down
23 changes: 15 additions & 8 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Task struct {
Organization string `json:"org"`
AuthorizationID ID `json:"authorizationID"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
Flux string `json:"flux"`
Every string `json:"every,omitempty"`
Expand Down Expand Up @@ -133,6 +134,7 @@ type TaskService interface {
// TaskCreate is the set of values to create a task.
type TaskCreate struct {
Flux string `json:"flux"`
Description string `json:"description,omitempty"`
Status string `json:"status,omitempty"`
OrganizationID ID `json:"orgID,omitempty"`
Organization string `json:"org,omitempty"`
Expand All @@ -153,8 +155,9 @@ func (t TaskCreate) Validate() error {

// TaskUpdate represents updates to a task. Options updates override any options set in the Flux field.
type TaskUpdate struct {
Flux *string `json:"flux,omitempty"`
Status *string `json:"status,omitempty"`
Flux *string `json:"flux,omitempty"`
Status *string `json:"status,omitempty"`
Description *string `json:"description,omitempty"`

// LatestCompleted us to set latest completed on startup to skip task catchup
LatestCompleted *string `json:"-"`
Expand All @@ -169,9 +172,10 @@ type TaskUpdate struct {
func (t *TaskUpdate) UnmarshalJSON(data []byte) error {
// this is a type so we can marshal string into durations nicely
jo := struct {
Flux *string `json:"flux,omitempty"`
Status *string `json:"status,omitempty"`
Name string `json:"name,omitempty"`
Flux *string `json:"flux,omitempty"`
Status *string `json:"status,omitempty"`
Name string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`

// Cron is a cron style time schedule that can be used in place of Every.
Cron string `json:"cron,omitempty"`
Expand All @@ -195,6 +199,7 @@ func (t *TaskUpdate) UnmarshalJSON(data []byte) error {
return err
}
t.Options.Name = jo.Name
t.Description = jo.Description
t.Options.Cron = jo.Cron
t.Options.Every = jo.Every
if jo.Offset != nil {
Expand All @@ -212,9 +217,10 @@ func (t *TaskUpdate) UnmarshalJSON(data []byte) error {

func (t TaskUpdate) MarshalJSON() ([]byte, error) {
jo := struct {
Flux *string `json:"flux,omitempty"`
Status *string `json:"status,omitempty"`
Name string `json:"name,omitempty"`
Flux *string `json:"flux,omitempty"`
Status *string `json:"status,omitempty"`
Name string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`

// Cron is a cron style time schedule that can be used in place of Every.
Cron string `json:"cron,omitempty"`
Expand All @@ -234,6 +240,7 @@ func (t TaskUpdate) MarshalJSON() ([]byte, error) {
jo.Name = t.Options.Name
jo.Cron = t.Options.Cron
jo.Every = t.Options.Every
jo.Description = t.Description
if t.Options.Offset != nil {
offset := *t.Options.Offset
jo.Offset = &offset
Expand Down