2022-02-25 11:34:09 -06:00
|
|
|
const serialize = require('../api/resolvers/serial')
|
|
|
|
|
|
|
|
function auction ({ models }) {
|
|
|
|
return async function ({ name }) {
|
|
|
|
console.log('running', name)
|
2022-03-03 12:56:02 -06:00
|
|
|
// get all items we need to check
|
2022-02-25 11:34:09 -06:00
|
|
|
const items = await models.item.findMany(
|
|
|
|
{
|
|
|
|
where: {
|
|
|
|
maxBid: {
|
|
|
|
not: null
|
|
|
|
},
|
|
|
|
status: {
|
|
|
|
not: 'STOPPED'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// for each item, run serialized auction function
|
2022-03-03 12:56:02 -06:00
|
|
|
items.forEach(async item => {
|
|
|
|
await serialize(models,
|
2023-07-26 19:18:42 -05:00
|
|
|
models.$executeRaw`SELECT run_auction(${item.id}::INTEGER)`)
|
2022-03-03 12:56:02 -06:00
|
|
|
})
|
2022-02-25 11:34:09 -06:00
|
|
|
|
|
|
|
console.log('done', name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { auction }
|