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