Skip to content

Commit

Permalink
ESSNTL-4817: fix ungrouped hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
psegedy committed Jul 21, 2023
1 parent 37ccc5d commit 84871b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base/database/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ func ReadReplicaConfigured() bool {
func InventoryHostsJoin(tx *gorm.DB, groups map[string]string) *gorm.DB {
tx = tx.Joins("JOIN inventory.hosts ih ON ih.id = sp.inventory_id")
if _, ok := groups[rbac.KeyGrouped]; !ok {
if _, ok := groups[rbac.KeyUngrouped]; ok {
// show only systems with '[]' group
return tx.Where("ih.groups = '[]'")
}
// return query without WHERE if there are no groups
return tx
}
Expand Down
1 change: 1 addition & 0 deletions base/database/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var testCases = []map[int64]map[string]string{
rbac.KeyUngrouped: "[]",
}},
{0: {rbac.KeyGrouped: `{"[{\"id\":\"non-existing-group\"}]"}`}},
{nUngrouped: {rbac.KeyUngrouped: "[]"}},
{nAll: {}},
}

Expand Down

0 comments on commit 84871b2

Please sign in to comment.