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): sort runs by most recently scheduled #14604

Merged
merged 1 commit into from
Aug 12, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Features
1. [14495](https://github.com/influxdata/influxdb/pull/14495): optional gzip compression of the query CSV response.
1. [14567](https://github.com/influxdata/influxdb/pull/14567): Add task types.
1. [14604](https://github.com/influxdata/influxdb/pull/14604): When getting task runs from the API, runs will be returned in order of most recently scheduled first.

### UI Improvements

Expand Down
1 change: 1 addition & 0 deletions task/backend/analytical_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func (as *AnalyticalStorage) FindRuns(ctx context.Context, filter influxdb.RunFi
|> group(columns: ["taskID"])
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> limit(n:%d)
|> sort(columns:["scheduledFor"], desc: true)

`, filter.Task.String(), filterPart, filter.Limit-len(runs))

Expand Down
19 changes: 10 additions & 9 deletions task/servicetest/servicetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,9 @@ func testRunStorage(t *testing.T, sys *System) {
t.Fatalf("retrieved wrong run ID; want %s, got %s", rc0.Created.RunID, runs[0].ID)
}

// Unspecified limit returns all three runs.
// Unspecified limit returns all three runs, sorted by most recently scheduled first.
runs, _, err = sys.TaskService.FindRuns(sys.Ctx, influxdb.RunFilter{Task: task.ID})

if err != nil {
t.Fatal(err)
}
Expand All @@ -1176,17 +1177,17 @@ func testRunStorage(t *testing.T, sys *System) {
t.Fatalf("expected empty FinishedAt, got %q", runs[0].FinishedAt)
}

if runs[1].ID != rc1.Created.RunID {
t.Fatalf("retrieved wrong run ID; want %s, got %s", rc1.Created.RunID, runs[1].ID)
if runs[2].ID != rc1.Created.RunID {
t.Fatalf("retrieved wrong run ID; want %s, got %s", rc2.Created.RunID, runs[1].ID)
}
if runs[1].StartedAt != startedAt.Add(time.Second).Format(time.RFC3339Nano) {
t.Fatalf("unexpected StartedAt; want %s, got %s", runs[0].StartedAt, startedAt.Add(time.Second))
if runs[2].StartedAt != startedAt.Add(time.Second).Format(time.RFC3339Nano) {
t.Fatalf("unexpected StartedAt; want %s, got %s", runs[1].StartedAt, startedAt.Add(time.Second))
}
if runs[1].Status != backend.RunSuccess.String() {
t.Fatalf("unexpected run status; want %s, got %s", backend.RunSuccess.String(), runs[0].Status)
if runs[2].Status != backend.RunSuccess.String() {
t.Fatalf("unexpected run status; want %s, got %s", backend.RunSuccess.String(), runs[2].Status)
}
if exp := startedAt.Add(time.Second * 2).Format(time.RFC3339Nano); runs[1].FinishedAt != exp {
t.Fatalf("unexpected FinishedAt; want %s, got %s", exp, runs[1].FinishedAt)
if exp := startedAt.Add(time.Second * 2).Format(time.RFC3339Nano); runs[2].FinishedAt != exp {
t.Fatalf("unexpected FinishedAt; want %s, got %s", exp, runs[2].FinishedAt)
}

// Look for a run that doesn't exist.
Expand Down