fix: customer list ordering with limit

This commit is contained in:
Rafael Taranto 2024-08-14 16:33:34 +01:00
parent 56ad9e6f00
commit b93a4c2088

View file

@ -538,6 +538,7 @@ function getCustomersList (phone = null, name = null, address = null, id = null,
AND ($6 IS NULL OR id_card_data::json->>'address' = $6) AND ($6 IS NULL OR id_card_data::json->>'address' = $6)
AND ($7 IS NULL OR id_card_data::json->>'documentNumber' = $7) AND ($7 IS NULL OR id_card_data::json->>'documentNumber' = $7)
AND ($8 IS NULL OR email = $8) AND ($8 IS NULL OR email = $8)
ORDER BY last_active DESC
limit $3` limit $3`
return db.any(sql, [ passableErrorCodes, anonymous.uuid, NUM_RESULTS, phone, name, address, id, email ]) return db.any(sql, [ passableErrorCodes, anonymous.uuid, NUM_RESULTS, phone, name, address, id, email ])
.then(customers => Promise.all(_.map(customer => .then(customers => Promise.all(_.map(customer =>