stacker.news/worker/auction.js

23 lines
502 B
JavaScript
Raw Normal View History

import serialize from '@/api/resolvers/serial.js'
2022-02-25 17:34:09 +00:00
2023-11-21 23:32:22 +00:00
export async function auction ({ models }) {
// get all items we need to check
const items = await models.item.findMany(
{
where: {
maxBid: {
not: null
},
status: {
not: 'STOPPED'
2022-02-25 17:34:09 +00:00
}
}
2023-11-21 23:32:22 +00:00
}
)
2022-02-25 17:34:09 +00:00
2023-11-21 23:32:22 +00:00
// for each item, run serialized auction function
items.forEach(async item => {
await serialize(models.$executeRaw`SELECT run_auction(${item.id}::INTEGER)`, { models })
2023-11-21 23:32:22 +00:00
})
2022-02-25 17:34:09 +00:00
}