mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
add host_hostname field to distributed query results row (#1081)
Add a hostname field to every distributed query result row in websocket response. By doing this calculation on the server, we're hoping to improve the rendering on the frontend client, which currently does the same calculation. Closes #1079
This commit is contained in:
parent
444aa96c06
commit
ac95b764eb
1 changed files with 10 additions and 1 deletions
|
|
@ -124,6 +124,14 @@ func (svc service) StreamCampaignResults(ctx context.Context, conn *websocket.Co
|
|||
|
||||
lastStatus := status.Status
|
||||
|
||||
// to improve performance of the frontend rendering the results table, we
|
||||
// add the "host_hostname" field to every row.
|
||||
mapHostnameRows := func(hostname string, rows []map[string]string) {
|
||||
for _, row := range rows {
|
||||
row["host_hostname"] = hostname
|
||||
}
|
||||
}
|
||||
|
||||
// Loop, pushing updates to results and expected totals
|
||||
for {
|
||||
select {
|
||||
|
|
@ -131,9 +139,10 @@ func (svc service) StreamCampaignResults(ctx context.Context, conn *websocket.Co
|
|||
// Receive a result and push it over the websocket
|
||||
switch res := res.(type) {
|
||||
case kolide.DistributedQueryResult:
|
||||
mapHostnameRows(res.Host.HostName, res.Rows)
|
||||
err = conn.WriteJSONMessage("result", res)
|
||||
if err != nil {
|
||||
fmt.Println("error writing to channel")
|
||||
svc.logger.Log("msg", "error writing to channel", "err", err)
|
||||
}
|
||||
status.ActualResults++
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue