<commit_before>var
  _ = require('underscore'),

  Configuration = require('../helpers/Configuration'),

  Result = require('../models/Result'),

  ImagesService = require('./Images');

function getQuestionResults (categoryData, surveyCategory, resultsId) {
  var
    results = [],
    questionData = {},
    cascadeData,
    cascadeMatch,
    questionResults = {};

  _.each(surveyCategory._questions, function (surveyQuestion) {
    questionResults = {};

    questionResults.id = surveyQuestion.id;

    questionData = _.find(categoryData.questions, function (question) {
      return question.id.toLowerCase() == questionResults.id.toLowerCase();
    });

    questionData = questionData ? questionData : {};

    cascadeMatch = /cascade/.test(surveyQuestion.type);

    if (questionData.result === 'undefined' || questionData.result === 'null') {
      questionData.result = undefined;
    }

    if (cascadeMatch) {
      questionResults.result = questionData.result;

      if (surveyQuestion.type === 'cascade1') {
        cascadeData = questionData.result ? true : false;

      } else if ((cascadeData && !questionData.result) || !cascadeData) {
        return;
      }
    } else if (surveyQuestion && (surveyQuestion.type === 'binary' || surveyQuestion.type === 'binary#image') && questionData.result) {
      ImagesService.saveImage(questionData.result, resultsId + '_' + questionResults.id + '.jpg');
      questionResults.result = resultsId + '_' + questionResults.id + '.jpg';
    } else {
      questionResults.result = questionData.result;
    }

    results.push(questionResults);
  });

  return results;
}

function getCategoryResults (resultsData, survey, resultId) {
  var
    resultCategory = {},
    categoryResults = {};

  return survey._categories.map(function (surveyCategory) {
    categoryResults = {};

    categoryResults.id = surveyCategory.id;<commit_msg>Fixed bug with invalide date format in the results<commit_after>var
  _ = require('underscore'),

  Configuration = require('../helpers/Configuration'),

  Result = require('../models/Result'),

  ImagesService = require('./Images');

function getQuestionResults (categoryData, surveyCategory, resultsId) {
  var
    results = [],
    questionData = {},
    cascadeData,
    cascadeMatch,
    questionResults = {};

  _.each(surveyCategory._questions, function (surveyQuestion) {
    questionResults = {};

    questionResults.id = surveyQuestion.id;

    questionData = _.find(categoryData.questions, function (question) {
      return question.id.toLowerCase() == questionResults.id.toLowerCase();
    });

    questionData = questionData ? questionData : {};

    cascadeMatch = /cascade/.test(surveyQuestion.type);

    if (questionData.result === 'undefined' || questionData.result === 'null') {
      questionData.result = undefined;
    }

    if (cascadeMatch) {
      questionResults.result = questionData.result;

      if (surveyQuestion.type === 'cascade1') {
        cascadeData = questionData.result ? true : false;

      } else if ((cascadeData && !questionData.result) || !cascadeData) {
        return;
      }
    } else if (surveyQuestion && (surveyQuestion.type === 'binary' || surveyQuestion.type === 'binary#image') && questionData.result) {
      ImagesService.saveImage(questionData.result, resultsId + '_' + questionResults.id + '.jpg');
      questionResults.result = resultsId + '_' + questionResults.id + '.jpg';
    } if (questionData.result && surveyQuestion.type === 'date') {
      questionResults.result = new Date(questionData.result);
    } else {
      questionResults.result = questionData.result;
    }

    results.push(questionResults);
  });

  return results;
}

function getCategoryResults (resultsData, survey, resultId) {
  var
    resultCategory = {},
    categoryResults = {};

  return survey._categories.map(function (surveyCategory) {
    categoryResults = {};

    categoryResults.id = surveyCategory.id;
{'fraction_non_alphanumeric': 0.13659401926001014, 'fraction_numerical': 0.0005068423720223011, 'mean_word_length': 3.563005780346821, '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': '625073', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1068, 'n_words': 208}