Hello!
I have a modified named query
SELECT DISTINCT
Asset.asset AS "Activo",
Asset.assetName AS "Descripcion",
Asset.EquipmentType || ' <' || EquipmentType.EquipmentTypeName || '>' AS "Clase equipo",
Asset.parentAsset AS "Activo padre",
Asset.businessUnit AS "Ud. negocio",
ALD.Value AS "Dato de nivel",
Asset.companyLevel AS "Nivel",
Asset.priority AS "Prioridad"
FROM
Asset
LEFT JOIN EquipmentType ON Asset.equipmentType = EquipmentType.EquipmentType
LEFT JOIN AssetLevelData ALD ON Asset.asset = ALD.asset
WHERE
Asset.company = 'APPLE' AND EquipmentType.company = 'APPLE'
AND (:tableFilter IS NULL OR Asset.businessUnit = :tableFilter)
AND (:nivelFilter IS NULL OR Asset.companyLevel = :nivelFilter)
ORDER BY
CASE
WHEN SubStr(Asset.businessUnit, 1, 3) IN ('CAT', 'BAL', 'MUR', 'VAL', 'AND', 'ARA', 'AST', 'CAL', 'EUS', 'GAL', 'NAV', 'RIO') THEN 2
WHEN SubStr(Asset.businessUnit, 1, 5) = 'MAD-F' THEN 0
WHEN SubStr(Asset.businessUnit, 1, 7) = 'MAD-PAR' THEN 0
ELSE 1
END,
Asset.businessUnit,
Asset.parentAsset,
Asset.asset
I added the parameters tableFilter and nivelFilter so I can aply both filters at once
-tableFilter custom filter comes from a custom property on my view that comes from a multiselect dropdown
-nivelFilter comes from 4 checkboxes,
def transform(self, value, quality, timestamp):
selected_levels = []
if value['chk_5']:
selected_levels.append('5')
if value['chk_6']:
selected_levels.append('6')
if value['chk_7']:
selected_levels.append('7')
if value['chk_8']:
selected_levels.append('8')
return ','.join(selected_levels) if selected_levels else None
When I choose more than one it doesn´t show any data on the table, just when I choose 1 checkbox it works.
Should I aply the filter to the namedQuery data without a parameter instead?
as:
def transform(self, value, quality, timestamp):
output = []
for row in value['data']:
nivel = row['Nivel']
if value['chk_5'] and nivel == 5:
output.append(row)
elif value['chk_6'] and nivel == 6:
output.append(row)
elif value['chk_7'] and nivel == 7:
output.append(row)
elif value['chk_8'] and nivel == 8:
output.append(row)
return output
Cheers!