<commit_before>'use strict'
const Rat = require('./../db').Rat
const Epic = require('./../db').Epic
const Query = require('./index')

/**
 * A class representing a rescue query
 */
class RescueQuery extends Query {
  /**
   * Create a sequelize rescue query from a set of parameters
   * @constructor
   * @param params
   * @param connection
   */
  constructor (params, connection) {
    super(params, connection)

    this._query.attributes = {
      exclude: [
        'deletedAt'
      ]
    }

    let rats = {}
    if (this._params.rats) {
      rats = this.subQuery(this._params.rats)
      delete this._params.rats
    }

    let firstLimpet = {}
    if (this._params.firstLimpet) {
      firstLimpet = this.subQuery(this._params.firstLimpet)
      delete this._params.firstLimpet
    }

    let epics = {}
    if (this._params.epics) {
      epics = this.subQuery(this._params.epics)
      delete this._params.epics
    }

    this._query.where = this._params

    this._query.include = [
      {
        where: rats,
        model: Rat,
        as: 'rats',
        require: false,
        through: {
          attributes: []
        }
      },
      {
        where: firstLimpet,
        model: Rat,
        as: 'firstLimpet',
        require: false
      },
      {
        model: Epic,
        as: 'epics',
        require: false
      }
    ]
  }
}

module.exports = RescueQuery<commit_msg>Make result counts distinct so Clapton will be happy<commit_after>'use strict'
const Rat = require('./../db').Rat
const Epic = require('./../db').Epic
const Query = require('./index')

/**
 * A class representing a rescue query
 */
class RescueQuery extends Query {
  /**
   * Create a sequelize rescue query from a set of parameters
   * @constructor
   * @param params
   * @param connection
   */
  constructor (params, connection) {
    super(params, connection)

    this._query.distinct = true

    this._query.attributes = {
      exclude: [
        'deletedAt'
      ]
    }

    let rats = {}
    if (this._params.rats) {
      rats = this.subQuery(this._params.rats)
      delete this._params.rats
    }

    let firstLimpet = {}
    if (this._params.firstLimpet) {
      firstLimpet = this.subQuery(this._params.firstLimpet)
      delete this._params.firstLimpet
    }

    let epics = {}
    if (this._params.epics) {
      epics = this.subQuery(this._params.epics)
      delete this._params.epics
    }

    this._query.where = this._params

    this._query.include = [
      {
        where: rats,
        model: Rat,
        as: 'rats',
        require: false,
        through: {
          attributes: []
        }
      },
      {
        where: firstLimpet,
        model: Rat,
        as: 'firstLimpet',
        require: false
      },
      {
        model: Epic,
        as: 'epics',
        require: false
      }
    ]
  }
}

module.exports = RescueQuery
{'fraction_non_alphanumeric': 0.121875, 'fraction_numerical': 0.0, 'mean_word_length': 1.8838838838838838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '83906', 'n_tokens_mistral': 910, 'n_tokens_neox': 878, 'n_words': 203}