<commit_before>const logger = require('./logger')(module)
const EventEmitter = require('events').EventEmitter
const Promise = require('bluebird')
const is = require('./is')
const enums = require('./enums')
const Job = require('./job')
const dbReview = require('./db-review')
const queueDb = require('./queue-db')
const queueProcess = require('./queue-process')
const queueAddJob = require('./queue-add-job')
const queueGetJob = require('./queue-get-job')
const queueFindJob = require('./queue-find-job')
const queueInterruption = require('./queue-interruption')
const queueCancelJob = require('./queue-cancel-job')
const queueRemoveJob = require('./queue-remove-job')
const queueReset = require('./queue-reset')
const queueSummary = require('./queue-summary')
const queueStop = require('./queue-stop')
const queueDrop = require('./queue-drop')
const jobOptions = require('./job-options')

class Queue extends EventEmitter {

  constructor (cxn, options) {
    super()
    logger('Queue Constructor', options)

    options = options || {}
    this._name = options.name || enums.options.name

    // The following properties are Populated
    // by the queueDb.attach(this, cxn) call below.
    this._r = false
    this._host = ''
    this._port = 0
    this._db = ''
    this._id = ''
    this._ready = false

    this._masterInterval = options.masterInterval == null
      ? enums.options.masterInterval : options.masterInterval
    this._jobOptions = jobOptions()
    this._changeFeedCursor = false
    this._paused = false
    this._running = 0
    this._changeFeed = options.changeFeed == null
      ? true : options.changeFeed
    this._concurrency = options.concurrency > 1
      ? options.concurrency : enums.options.concurrency
    this._removeFinishedJobs = options.removeFinishedJobs == null
      ? enums.options.removeFinishedJobs : options.removeFinishedJobs
    this._handler = false
    queueDb.attach(this, cxn)
  }

  get name () { return this._name }
  get id () { return this._id }
  get host () { return this._host }
  get port () { return this._port }
  get db () { return this._db }
  get r () { return this._r }
  get changeFeed () { return this._changeFeed }
  get master () { return this._masterInterval > 0 }
  get masterInterval () { return this._masterInterval }
  get jobOptions () { return this._jobOptions }
  get removeFinishedJobs () { return this._removeFinishedJobs }
  get running () { return this._running }
  get concurrency () { return this._concurrency }
  get paused () { return this._paused }
  get idle () { return this._running < 1 }

  set jobOptions (options) {
    logger('set jobOptions', options)
    this._jobOptions = jobOptions(options, this._jobOptions)
  }

  set concurrency (value) {
    logger('set concurrency', value)
    if (!is.integer(value) || value < 1) {
      const err = new Error(enums.message.concurrencyInvalid)
      logger('Event: concurrency error', err, q.id)
      this.emit(enums.status.error, err, q.id)
      return
    }
    this._concurrency = value
  }

  createJob (jobData) {
    logger('createJob', jobData)
    jobData = jobData == null ? this.jobOptions : jobData
    return new Job(this, jobData)
  }

  addJob (job) {
    logger('addJob', job)
    return this.ready().then(() => {
      return queueAddJob(this, job)
    }).catch((err) => {<commit_msg>Fixed q.id<commit_after>const logger = require('./logger')(module)
const EventEmitter = require('events').EventEmitter
const Promise = require('bluebird')
const is = require('./is')
const enums = require('./enums')
const Job = require('./job')
const dbReview = require('./db-review')
const queueDb = require('./queue-db')
const queueProcess = require('./queue-process')
const queueAddJob = require('./queue-add-job')
const queueGetJob = require('./queue-get-job')
const queueFindJob = require('./queue-find-job')
const queueInterruption = require('./queue-interruption')
const queueCancelJob = require('./queue-cancel-job')
const queueRemoveJob = require('./queue-remove-job')
const queueReset = require('./queue-reset')
const queueSummary = require('./queue-summary')
const queueStop = require('./queue-stop')
const queueDrop = require('./queue-drop')
const jobOptions = require('./job-options')

class Queue extends EventEmitter {

  constructor (cxn, options) {
    super()
    logger('Queue Constructor', options)

    options = options || {}
    this._name = options.name || enums.options.name

    // The following properties are Populated
    // by the queueDb.attach(this, cxn) call below.
    this._r = false
    this._host = ''
    this._port = 0
    this._db = ''
    this._id = ''
    this._ready = false

    this._masterInterval = options.masterInterval == null
      ? enums.options.masterInterval : options.masterInterval
    this._jobOptions = jobOptions()
    this._changeFeedCursor = false
    this._paused = false
    this._running = 0
    this._changeFeed = options.changeFeed == null
      ? true : options.changeFeed
    this._concurrency = options.concurrency > 1
      ? options.concurrency : enums.options.concurrency
    this._removeFinishedJobs = options.removeFinishedJobs == null
      ? enums.options.removeFinishedJobs : options.removeFinishedJobs
    this._handler = false
    queueDb.attach(this, cxn)
  }

  get name () { return this._name }
  get id () { return this._id }
  get host () { return this._host }
  get port () { return this._port }
  get db () { return this._db }
  get r () { return this._r }
  get changeFeed () { return this._changeFeed }
  get master () { return this._masterInterval > 0 }
  get masterInterval () { return this._masterInterval }
  get jobOptions () { return this._jobOptions }
  get removeFinishedJobs () { return this._removeFinishedJobs }
  get running () { return this._running }
  get concurrency () { return this._concurrency }
  get paused () { return this._paused }
  get idle () { return this._running < 1 }

  set jobOptions (options) {
    logger('set jobOptions', options)
    this._jobOptions = jobOptions(options, this._jobOptions)
  }

  set concurrency (value) {
    logger('set concurrency', value)
    if (!is.integer(value) || value < 1) {
      const err = new Error(enums.message.concurrencyInvalid)
      logger('Event: concurrency error', err, this.id)
      this.emit(enums.status.error, err, this.id)
      return
    }
    this._concurrency = value
  }

  createJob (jobData) {
    logger('createJob', jobData)
    jobData = jobData == null ? this.jobOptions : jobData
    return new Job(this, jobData)
  }

  addJob (job) {
    logger('addJob', job)
    return this.ready().then(() => {
      return queueAddJob(this, job)
    }).catch((err) => {
{'fraction_non_alphanumeric': 0.13456069450681035, 'fraction_numerical': 0.001796138302649304, 'mean_word_length': 3.451698867421719, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3042713', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1933, 'n_words': 495}