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

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

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

module.exports = { queue, connection, ensureHotDealListRepeatable }
