<commit_before>var rethinkdb = require( 'rethinkdb' )


var QueryParser = function( provider ) {
  this._provider = provider
}

/**
 * Parses the query string, queries are expected to
 * be send as JSON. The full name would look like this
 *
 * search?{ "table": "people", "query": [[ "name", "ma", "Wolf" ], [ "age", "gt", "25" ] ] }
 *
 * The structure is an array of filter conditions. Each filter condition
 * is expresses as [ "<field>", "<operator>", "value" ]
 *
 * Supported operators are
 *
 * "eq" (equals)
 * "match" (RegEx match)
 * "gt" (greater than)
 * "lt" (lesser than)
 * "ne" (not equal)
 *
 * @todo  Support for OR might come in handy
 *
 * @param   {String} name The recordName for the list, including search parameters
 *
 * @public
 * @returns {Object} query
 */
QueryParser.prototype.createQuery = function( parsedInput ) {
  var row,
    condition,
    query = null,
    i

  for( i = 0; i < parsedInput.query.length; i++ ) {
    condition = parsedInput.query[ i ]

    row = rethinkdb.row( condition[ 0 ] )[ condition[ 1 ] ]( condition[ 2 ] )

    if( query === null ) {
      query = row
    } else {
      query = query.and( row )
    }
  }

  return { table: parsedInput.table, filter: query }
}

/**
 * Receives a string like<commit_msg>Fixes #23<commit_after>var rethinkdb = require( 'rethinkdb' )


var QueryParser = function( provider ) {
  this._provider = provider
}

/**
 * Parses the query string, queries are expected to
 * be send as JSON. The full name would look like this
 *
 * search?{ "table": "people", "query": [[ "name", "ma", "Wolf" ], [ "age", "gt", "25" ] ] }
 *
 * The structure is an array of filter conditions. Each filter condition
 * is expresses as [ "<field>", "<operator>", "value" ]
 *
 * Supported operators are
 *
 * "eq" (equals)
 * "match" (RegEx match)
 * "gt" (greater than)
 * "lt" (lesser than)
 * "ne" (not equal)
 *
 * @todo  Support for OR might come in handy
 *
 * @param   {String} name The recordName for the list, including search parameters
 *
 * @public
 * @returns {Object} query
 */
QueryParser.prototype.createQuery = function( parsedInput ) {
  var row,
    condition,
    query = true,
    i

  for( i = 0; i < parsedInput.query.length; i++ ) {
    condition = parsedInput.query[ i ]

    row = rethinkdb.row( condition[ 0 ] )[ condition[ 1 ] ]( condition[ 2 ] )

    if( query === true ) {
      query = row
    } else {
      query = query.and( row )
    }
  }

  return { table: parsedInput.table, filter: query }
}

/**
 * Receives a string like
{'fraction_non_alphanumeric': 0.14901185770750988, 'fraction_numerical': 0.005533596837944664, 'mean_word_length': 3.0302547770700636, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 7, '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': '2929056', 'n_tokens_mistral': 841, 'n_tokens_neox': 811, 'n_words': 280}