Show all client metadata filter options
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 44s

This commit is contained in:
Cauê Faleiros
2026-06-23 15:06:41 -03:00
parent 06faadab5f
commit b7a2059070
2 changed files with 13 additions and 19 deletions

View File

@@ -684,40 +684,32 @@ const getClientAnalytics = async (range = {}) => {
return clients;
};
const getClientFilterOptions = async (range = {}) => {
const dateRange = {
start: range.start,
end: range.end
};
const { params, whereClause } = buildDateFilter(dateRange);
const getClientFilterOptions = async () => {
const [marketplaceResult, salesChannelResult, sellerResult] = await Promise.all([
pool.query(`
SELECT DISTINCT NULLIF(TRIM(marketplace), '') as value
FROM orders
${whereClause}
AND NULLIF(TRIM(marketplace), '') IS NOT NULL
WHERE NULLIF(TRIM(marketplace), '') IS NOT NULL
ORDER BY value ASC;
`, params),
`),
pool.query(`
SELECT DISTINCT NULLIF(TRIM(canal_venda), '') as value
FROM orders
${whereClause}
AND NULLIF(TRIM(canal_venda), '') IS NOT NULL
WHERE NULLIF(TRIM(canal_venda), '') IS NOT NULL
ORDER BY value ASC;
`, params),
`),
pool.query(`
SELECT
NULLIF(TRIM(id_vendedor), '') as id,
NULLIF(TRIM(nome_vendedor), '') as name
FROM orders
${whereClause}
AND (
WHERE (
NULLIF(TRIM(id_vendedor), '') IS NOT NULL
OR NULLIF(TRIM(nome_vendedor), '') IS NOT NULL
)
GROUP BY id, name
ORDER BY COALESCE(name, id) ASC, id ASC;
`, params)
`)
]);
const sellerOptionsByValue = new Map();