mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Return count of hosts in targets search for each label (#480)
This commit is contained in:
parent
9c38d6d19e
commit
752710ccf1
1 changed files with 6 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ type hostSearchResult struct {
|
|||
type labelSearchResult struct {
|
||||
kolide.Label
|
||||
DisplayText string `json:"display_text"`
|
||||
Count uint `json:"count"`
|
||||
}
|
||||
|
||||
type targetsData struct {
|
||||
|
|
@ -70,10 +71,15 @@ func makeSearchTargetsEndpoint(svc kolide.Service) endpoint.Endpoint {
|
|||
}
|
||||
|
||||
for _, label := range results.Labels {
|
||||
count, err := svc.CountHostsInTargets(ctx, nil, []uint{label.ID})
|
||||
if err != nil {
|
||||
return searchTargetsResponse{Err: err}, nil
|
||||
}
|
||||
targets.Labels = append(targets.Labels,
|
||||
labelSearchResult{
|
||||
label,
|
||||
label.Name,
|
||||
count,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue