(batchAPIs []schema.APIResponse, envNames []string)
| 41 | ) |
| 42 | |
| 43 | func batchAPIsTable(batchAPIs []schema.APIResponse, envNames []string) table.Table { |
| 44 | rows := make([][]interface{}, 0, len(batchAPIs)) |
| 45 | |
| 46 | for i, batchAPI := range batchAPIs { |
| 47 | if batchAPI.Metadata == nil { |
| 48 | continue |
| 49 | } |
| 50 | lastAPIUpdated := time.Unix(batchAPI.Metadata.LastUpdated, 0) |
| 51 | latestStartTime := time.Time{} |
| 52 | latestJobID := "-" |
| 53 | runningJobs := 0 |
| 54 | |
| 55 | for _, job := range batchAPI.BatchJobStatuses { |
| 56 | if job.StartTime.After(latestStartTime) { |
| 57 | latestStartTime = job.StartTime |
| 58 | latestJobID = job.ID + fmt.Sprintf(" (submitted %s ago)", libtime.SinceStr(&latestStartTime)) |
| 59 | } |
| 60 | |
| 61 | if job.Status.IsInProgress() { |
| 62 | runningJobs++ |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | rows = append(rows, []interface{}{ |
| 67 | envNames[i], |
| 68 | batchAPI.Metadata.Name, |
| 69 | runningJobs, |
| 70 | latestJobID, |
| 71 | libtime.SinceStr(&lastAPIUpdated), |
| 72 | }) |
| 73 | } |
| 74 | |
| 75 | return table.Table{ |
| 76 | Headers: []table.Header{ |
| 77 | {Title: _titleEnvironment}, |
| 78 | {Title: _titleBatchAPI}, |
| 79 | {Title: _titleJobCount}, |
| 80 | {Title: _titleLatestJobID}, |
| 81 | {Title: _titleLastUpdated}, |
| 82 | }, |
| 83 | Rows: rows, |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | func batchAPITable(batchAPI schema.APIResponse) string { |
| 88 | jobRows := make([][]interface{}, 0, len(batchAPI.BatchJobStatuses)) |
no test coverage detected