From e0799bbc59950cdbb8a6cf9e7e3f45c7459f52cd Mon Sep 17 00:00:00 2001 From: Zach Wasserman Date: Wed, 30 Jun 2021 09:28:45 -0700 Subject: [PATCH] Include Team names when listing label hosts (#1267) Fixes #1266 --- server/datastore/mysql/labels.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/datastore/mysql/labels.go b/server/datastore/mysql/labels.go index 174b450210..f4c4db1a86 100644 --- a/server/datastore/mysql/labels.go +++ b/server/datastore/mysql/labels.go @@ -402,7 +402,7 @@ func (d *Datastore) ListLabelsForHost(hid uint) ([]*fleet.Label, error) { // with fleet.Label referened by Label ID func (d *Datastore) ListHostsInLabel(filter fleet.TeamFilter, lid uint, opt fleet.HostListOptions) ([]*fleet.Host, error) { sql := fmt.Sprintf(` - SELECT h.* + SELECT h.*, (SELECT name FROM teams t WHERE t.id = h.team_id) AS team_name FROM label_membership lm JOIN hosts h ON lm.host_id = h.id @@ -429,7 +429,7 @@ func (d *Datastore) ListUniqueHostsInLabels(filter fleet.TeamFilter, labels []ui } sqlStatement := fmt.Sprintf(` - SELECT DISTINCT h.* + SELECT DISTINCT h.*, (SELECT name FROM teams t WHERE t.id = h.team_id) AS team_name FROM label_membership lm JOIN hosts h ON lm.host_id = h.id