Fix seller filter options query
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m13s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m13s
This commit is contained in:
@@ -701,14 +701,18 @@ const getClientFilterOptions = async () => {
|
|||||||
ORDER BY value ASC;
|
ORDER BY value ASC;
|
||||||
`),
|
`),
|
||||||
pool.query(`
|
pool.query(`
|
||||||
SELECT
|
WITH seller_options AS (
|
||||||
NULLIF(TRIM(id_vendedor), '') as id,
|
SELECT
|
||||||
NULLIF(TRIM(nome_vendedor), '') as name
|
NULLIF(TRIM(id_vendedor), '') as id,
|
||||||
FROM orders
|
NULLIF(TRIM(nome_vendedor), '') as name
|
||||||
WHERE (
|
FROM orders
|
||||||
NULLIF(TRIM(id_vendedor), '') IS NOT NULL
|
WHERE (
|
||||||
OR NULLIF(TRIM(nome_vendedor), '') IS NOT NULL
|
NULLIF(TRIM(id_vendedor), '') IS NOT NULL
|
||||||
)
|
OR NULLIF(TRIM(nome_vendedor), '') IS NOT NULL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
SELECT id, name
|
||||||
|
FROM seller_options
|
||||||
GROUP BY id, name
|
GROUP BY id, name
|
||||||
ORDER BY COALESCE(name, id) ASC, id ASC;
|
ORDER BY COALESCE(name, id) ASC, id ASC;
|
||||||
`)
|
`)
|
||||||
|
|||||||
@@ -656,6 +656,7 @@ test('getClientFilterOptions returns all distinct order metadata options', async
|
|||||||
assert.doesNotMatch(call.sql, /data_pedido_date <=/);
|
assert.doesNotMatch(call.sql, /data_pedido_date <=/);
|
||||||
});
|
});
|
||||||
assert.match(calls[0].sql, /WHERE NULLIF\(TRIM\(marketplace\), ''\) IS NOT NULL/);
|
assert.match(calls[0].sql, /WHERE NULLIF\(TRIM\(marketplace\), ''\) IS NOT NULL/);
|
||||||
|
assert.match(calls[2].sql, /WITH seller_options AS/);
|
||||||
assert.match(calls[2].sql, /NULLIF\(TRIM\(nome_vendedor\), ''\) IS NOT NULL/);
|
assert.match(calls[2].sql, /NULLIF\(TRIM\(nome_vendedor\), ''\) IS NOT NULL/);
|
||||||
assert.deepEqual(options.marketplaces, ['Mercado Livre', 'Shopee']);
|
assert.deepEqual(options.marketplaces, ['Mercado Livre', 'Shopee']);
|
||||||
assert.deepEqual(options.salesChannels, ['Online']);
|
assert.deepEqual(options.salesChannels, ['Online']);
|
||||||
|
|||||||
Reference in New Issue
Block a user