stacker.news/worker/auction.js

31 lines
656 B
JavaScript
Raw Normal View History

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)
// 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
items.forEach(async item => {
await serialize(models,
models.$executeRaw`SELECT run_auction(${item.id})`)
})
2022-02-25 17:34:09 +00:00
console.log('done', name)
}
}
module.exports = { auction }