зеркало из https://github.com/mozilla/mig.git
[minor] handle the case of no agent stats in api dashboard
This commit is contained in:
Родитель
7f274d9736
Коммит
2555a62e09
|
@ -408,12 +408,17 @@ func getDashboard(respWriter http.ResponseWriter, request *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if len(stats) != 1 {
|
if len(stats) > 1 {
|
||||||
panic(fmt.Sprintf("expected 1 set of agents stats, got %d", len(stats)))
|
panic(fmt.Sprintf("expected 1 set of agents stats, got %d", len(stats)))
|
||||||
}
|
}
|
||||||
agentsStats = stats[0]
|
if len(stats) == 1 {
|
||||||
sumItem, err := agentsSummaryToItem(agentsStats, ctx)
|
agentsStats = stats[0]
|
||||||
resource.AddItem(sumItem)
|
sumItem, err := agentsSummaryToItem(agentsStats, ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
resource.AddItem(sumItem)
|
||||||
|
}
|
||||||
|
|
||||||
// add the last 10 actions
|
// add the last 10 actions
|
||||||
actions, err := ctx.DB.LastActions(10)
|
actions, err := ctx.DB.LastActions(10)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче