Sha256: 7915cddee76fb63337a6d6cc37d8a0c89027ad75ef176a0d94737ee328197ecf
Contents?: true
Size: 867 Bytes
Versions: 41
Compression:
Stored size: 867 Bytes
Contents
export const buildHostQuery = (selected, search) => { const { hosts, hostCollections, hostGroups } = selected; const hostsSearch = `id ^ (${hosts.map(({ id }) => id).join(',')})`; const hostCollectionsSearch = `host_collection_id ^ (${hostCollections .map(({ id }) => id) .join(',')})`; const hostGroupsSearch = `hostgroup_id ^ (${hostGroups .map(({ id }) => id) .join(',')})`; const queryParts = [ hosts.length ? hostsSearch : false, hostCollections.length ? hostCollectionsSearch : false, hostGroups.length ? hostGroupsSearch : false, search.length ? search : false, ].filter(Boolean); if (queryParts.length === 0) { return 'name=a AND name=b'; } if (queryParts.length === 1) { return queryParts[0] || 'name=a AND name=b'; } return queryParts.map(p => `(${p})`).join(' or ') || 'name=a AND name=b'; };
Version data entries
41 entries across 41 versions & 1 rubygems