<commit_before>//  Cycles through any meta data passed via the query string
//  and filters out records not matching the meta data.

'use strict';

const _ = require('underscore');
const winston = require('winston');

// Filter the result set with the meta query if one exists
function apply_unstructured_query(hook) {
  if(hook.params.meta) {
    hook.result.data = hook.result.data.filter(current => {
      if (_.has(current, 'meta')) {
        var match = true;
        _.each(_.keys(hook.params.meta), function(key) {
          if(current.meta == null || current.meta[key] != hook.params.meta[key]) {
            match = false;
          }
        })
        return match;
      }
    });
  }
}

module.exports = function (hook) {
  return apply_unstructured_query(hook)<commit_msg>Fixed bug with filter referencing incorrect dataset<commit_after>//  Cycles through any meta data passed via the query string
//  and filters out records not matching the meta data.

'use strict';

const _ = require('underscore');

// Filter the result set with the meta query if one exists
function apply_unstructured_query(hook) {
  if(hook.params.meta) {
    hook.result = hook.result.filter(current => {
      if (_.has(current, 'meta')) {
        var match = true;
        _.each(_.keys(hook.params.meta), function(key) {
          if(current.meta == null || current.meta[key] != hook.params.meta[key]) {
            match = false;
          }
        })
        return match;
      }
    });
  }
}

module.exports = function (hook) {
  return apply_unstructured_query(hook)
{'fraction_non_alphanumeric': 0.12388250319284802, 'fraction_numerical': 0.0, 'mean_word_length': 2.739856801909308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '826181', 'n_tokens_mistral': 465, 'n_tokens_neox': 455, 'n_words': 130}