function interceptJobEndTimes(duration, durationType) {
    let now;
    kue.Job.rangeByStateAsync = function (state, from, to, order) {
      if (!now) now = Date.now();
      return originalRangeByStateAsync(state, from, to, order)
      .then((jobs) => {
        jobs.forEach((job) => {
          if (durationType === 'staggered') {
            job.updated_at = now - job.id * duration;
          } else if (durationType === 'non-contiguous' && Array.isArray(duration)) {
            job.updated_at = now - duration[job.id % duration.length];
          }
        });
        return jobs;
      });
    };
  }
// to set mock end times for testing
to set mock end times for testing
to set mock end times for testing
function interceptJobEndTimes(duration, durationType) {
    let now;
    kue.Job.rangeByStateAsync = function (state, from, to, order) {
      if (!now) now = Date.now();
      return originalRangeByStateAsync(state, from, to, order)
      .then((jobs) => {
        jobs.forEach((job) => {
          if (durationType === 'staggered') {
            job.updated_at = now - job.id * duration;
          } else if (durationType === 'non-contiguous' && Array.isArray(duration)) {
            job.updated_at = now - duration[job.id % duration.length];
          }
        });
        return jobs;
      });
    };
  }
function interceptJobEndTimes ( duration , durationType ) { let now ; kue . Job . rangeByStateAsync = function ( state , from , to , order ) { if ( ! now ) now = Date . now ( ) ; return originalRangeByStateAsync ( state , from , to , order ) . then ( ( jobs ) => { jobs . forEach ( ( job ) => { if ( durationType === 'staggered' ) { job . updated_at = now - job . id * duration ; } else if ( durationType === 'non-contiguous' && Array . isArray ( duration ) ) { job . updated_at = now - duration [ job . id % duration . length ] ; } } ) ; return jobs ; } ) ; } ; }
to set mock end times for testing
to set mock end times for testing