src/server/views/dashboard/queueJobsByState.js
async function _json(req, res) {
  const { queueName, queueHost, state } = req.params;
  const {Queues} = req.app.locals;
  const queue = await Queues.get(queueName, queueHost);
  if (!queue) return res.status(404).json({ message: 'Queue not found' });

  if (!isValidState(state, queue.IS_BEE)) return res.status(400).json({ message: `Invalid state requested: ${state}` });

  let jobs;
  if (queue.IS_BEE) {
    jobs = await queue.getJobs(state, { size: 1000 });
    jobs = jobs.map((j) => _.pick(j, 'id', 'progress', 'data', 'options', 'status'));
  } else {
    jobs = await queue[`get${_.capitalize(state)}`](0, 1000);
    jobs = jobs.map((j) => j.toJSON());
  }

  const filename = `${queueName}-${state}-dump.json`;

  res.setHeader('Content-disposition', `attachment; filename=${filename}`);
  res.setHeader('Content-type', 'application/json');
  res.write(JSON.stringify(jobs, null, 2), () => res.end());
}
async function _json(req, res) {
  const { queueName, queueHost, state } = req.params;
  const {Queues} = req.app.locals;
  const queue = await Queues.get(queueName, queueHost);
  if (!queue) return res.status(404).json({ message: 'Queue not found' });

  if (!isValidState(state, queue.IS_BEE)) return res.status(400).json({ message: `Invalid state requested: ${state}` });

  let jobs;
  if (queue.IS_BEE) {
    jobs = await queue.getJobs(state, { size: 1000 });
    jobs = jobs.map((j) => _.pick(j, 'id', 'progress', 'data', 'options', 'status'));
  } else {
    jobs = await queue[`get${_.capitalize(state)}`](0, 1000);
    jobs = jobs.map((j) => j.toJSON());
  }

  const filename = `${queueName}-${state}-dump.json`;

  res.setHeader('Content-disposition', `attachment; filename=${filename}`);
  res.setHeader('Content-type', 'application/json');
  res.write(JSON.stringify(jobs, null, 2), () => res.end());
}
async function _json ( req , res ) { const { queueName , queueHost , state } = req . params ; const { Queues } = req . app . locals ; const queue = await Queues . get ( queueName , queueHost ) ; if ( ! queue ) return res . status ( 404 ) . json ( { message : 'Queue not found' } ) ; if ( ! isValidState ( state , queue . IS_BEE ) ) return res . status ( 400 ) . json ( { message : ` ${ state } ` } ) ; let jobs ; if ( queue . IS_BEE ) { jobs = await queue . getJobs ( state , { size : 1000 } ) ; jobs = jobs . map ( ( j ) => _ . pick ( j , 'id' , 'progress' , 'data' , 'options' , 'status' ) ) ; } else { jobs = await queue [ ` ${ _ . capitalize ( state ) } ` ] ( 0 , 1000 ) ; jobs = jobs . map ( ( j ) => j . toJSON ( ) ) ; } const filename = ` ${ queueName } ${ state } ` ; res . setHeader ( 'Content-disposition' , ` ${ filename } ` ) ; res . setHeader ( 'Content-type' , 'application/json' ) ; res . write ( JSON . stringify ( jobs , null , 2 ) , ( ) => res . end ( ) ) ; }
Returns the queue jobs in the requested state as a json document.

@prop {Object} req express request object
@prop {Object} res express response object
Returns the queue jobs in the requested state as a json document .