2024-03-20 00:37:31 +00:00
|
|
|
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,
|
|
|
|
models.$executeRaw`SELECT run_auction(${item.id}::INTEGER)`)
|
|
|
|
})
|
2022-02-25 17:34:09 +00:00
|
|
|
}
|