MCPcopy
hub / github.com/cortexlabs/cortex / batchAPIsTable

Function batchAPIsTable

cli/cmd/lib_batch_apis.go:43–85  ·  view source on GitHub ↗
(batchAPIs []schema.APIResponse, envNames []string)

Source from the content-addressed store, hash-verified

41)
42
43func 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
87func batchAPITable(batchAPI schema.APIResponse) string {
88 jobRows := make([][]interface{}, 0, len(batchAPI.BatchJobStatuses))

Callers 2

getAPIsInAllEnvironmentsFunction · 0.85
getAPIsByEnvFunction · 0.85

Calls 1

IsInProgressMethod · 0.80

Tested by

no test coverage detected