Add sort and limit in customers batch
This commit is contained in:
parent
69ae1401a3
commit
ebc346c6ae
2 changed files with 7 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ const uuid = require('uuid')
|
|||
const _ = require('lodash/fp')
|
||||
const BN = require('./bn')
|
||||
const anonymous = require('../lib/constants').anonymousCustomer
|
||||
const NUM_RESULTS = 20
|
||||
|
||||
function add (customer) {
|
||||
const sql = 'insert into customers (id, phone, phone_at) values ($1, $2, now()) returning *'
|
||||
|
|
@ -34,8 +35,10 @@ function getDailyVolume (id) {
|
|||
}
|
||||
|
||||
function batch () {
|
||||
const sql = `select * from customers where id not in ($1)`
|
||||
return db.any(sql, [anonymous.uuid])
|
||||
const sql = `select * from customers
|
||||
where id != $1
|
||||
order by created desc limit $2`
|
||||
return db.any(sql, [ anonymous.uuid, NUM_RESULTS ])
|
||||
}
|
||||
|
||||
module.exports = { add, get, batch }
|
||||
|
|
|
|||
|
|
@ -31964,12 +31964,12 @@ var _user$project$Common_Customer_Decoder$customerDecoder = A3(
|
|||
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$optional,
|
||||
'phone',
|
||||
_elm_lang$core$Json_Decode$string,
|
||||
'--',
|
||||
'',
|
||||
A4(
|
||||
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$optional,
|
||||
'name',
|
||||
_elm_lang$core$Json_Decode$string,
|
||||
'--',
|
||||
'',
|
||||
A3(
|
||||
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$required,
|
||||
'id',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue