const { Queue } = require("bullmq")
const { getRedisConnectionOptions } = require("../services/redis/connection")

const connection = getRedisConnectionOptions()
const queue = new Queue("newdeal-list", { connection })

async function ensureNewDealListRepeatable() {
  return queue.add(
    "build-newdeal-list",
    {},
    {
      jobId: "newdeal-list-builder",
      repeat: { every: 30000 },
      removeOnComplete: true,
      removeOnFail: 100,
    }
  )
}

module.exports = { queue, connection, ensureNewDealListRepeatable }
