<commit_before>'use strict';

angular.module('confRegistrationWebApp')
  .service('ConferenceHelper', function ConferenceHelper(U) {

    this.getCompletedRegistrations = function (registrations) {
      return _.filter(registrations, function (item) {
        return item.completed !== false;
      });
    };

    this.getContentByBlockType = function (value, type) {

      if (U.isEmpty(value)) {

        var content = [];

        if (angular.equals(type, 'nameQuestion')) {
          content.push('');
        }
        else if (angular.equals(type, 'addressQuestion')) {
          content.push('');
          content.push('');
          content.push('');
          content.push('');
        }

        content.push('');

        return content;
      }

      return _getContentByBlockType(value, type);
    };

    var _getContentByBlockType = function (value, type) {
      var content = [];

      if (angular.equals(type, 'nameQuestion')) {
        content.push(window.S(U.getValue(value.firstName)).capitalize());
        content.push(window.S(U.getValue(value.lastName)).capitalize());
      }
      else if (angular.equals(type, 'emailQuestion')) {
        content.push(U.getValue(value));
      }
      else if (angular.equals(type, 'textQuestion')) {
        content.push(U.getValue(value));
      }
      else if (angular.equals(type, 'checkboxQuestion')) {
        content.push(U.joiner(U.getValue(U.getKeysWhere(value, true)), ' '));
      }
      else if (angular.equals(type, 'phoneQuestion')) {
        content.push(U.getValue(value));
      }
      else if (angular.equals(type, 'radioQuestion')) {
        content.push(U.getValue(value));
      }
      else if (angular.equals(type, 'selectQuestion')) {
        content.push(U.getValue(value));
      }
      else if (angular.equals(type, 'numberQuestion')) {
        content.push(U.getValue(value));
      }
      else if (angular.equals(type, 'addressQuestion')) {
        content.push(U.getValue(value.address1));
        content.push(U.getValue(value.address2));
        content.push(U.getValue(value.city));
        content.push(U.getValue(value.state));
        content.push(U.getValue(value.zip));
      }

      return content;
    };

    this.getRegistrantName = function (answers, blocks) {
      var answer = this.findAnswerByBlockType(answers, blocks, 'nameQuestion', 'NAME');

      return this.getContentByBlockType(U.isEmpty(answer) ? answer : answer.value, 'nameQuestion');
    };

    this.findAnswerByBlockType = function (answers, blocks, blockType, profileType) {
      var block = this.findBlockByType(blocks, blockType, profileType);
      if (!U.isEmpty(block)) {
        return this.findAnswerByBlockId(answers, block.id);
      }

      block = this.findBlockByType(blocks, blockType);
      if (!U.isEmpty(block)) {
        return this.findAnswerByBlockId(answers, block.id);
      }

      return null;
    };

    this.findBlockByType = function (blocks, blockType, profileType) {
      return _.find(blocks, function (block) {
        if (!U.isEmpty(profileType)) {
          return block.type === blockType && block.profileType === profileType;
        }

        return block.type === blockType && block.type;
      });
    };

    this.findAnswerByBlockId = function (answers, blockId) {
      return _.find(answers, function (answer) {
        return angular.equals(answer.blockId, blockId);
      });
    };

    this.getPageBlocks = function (pages) {
      var blocks = [];
      angular.forEach(pages, function (page) {
        angular.forEach(page.blocks, function (block) {
          if (block.type.indexOf('Content') === -1) {
            blocks.push(block);
          }
        });
      });

      return blocks;
    };

    this.hasCost = function (conference) {
      return conference.conferenceCost && conference.conferenceCost > 0;
    };
  });
<commit_msg>Registration export fix for missing question types<commit_after>'use strict';

angular.module('confRegistrationWebApp')
  .service('ConferenceHelper', function ConferenceHelper(U) {

    this.getCompletedRegistrations = function (registrations) {
      return _.filter(registrations, function (item) {
        return item.completed !== false;
      });
    };

    this.getContentByBlockType = function (value, type) {

      if (U.isEmpty(value)) {

        var content = [];

        if (angular.equals(type, 'nameQuestion')) {
          content.push('');
        }
        else if (angular.equals(type, 'addressQuestion')) {
          content.push('');
          content.push('');
          content.push('');
          content.push('');
        }

        content.push('');

        return content;
      }

      return _getContentByBlockType(value, type);
    };

    var _getContentByBlockType = function (value, type) {
      var content = [];

      if (angular.equals(type, 'nameQuestion')) {
        content.push(window.S(U.getValue(value.firstName)).capitalize());
        content.push(window.S(U.getValue(value.lastName)).capitalize());
      }
      else if (angular.equals(type, 'checkboxQuestion')) {
        content.push(U.joiner(U.getValue(U.getKeysWhere(value, true)), ' '));
      }
      else if (angular.equals(type, 'addressQuestion')) {
        content.push(U.getValue(value.address1));
        content.push(U.getValue(value.address2));
        content.push(U.getValue(value.city));
        content.push(U.getValue(value.state));
        content.push(U.getValue(value.zip));
      } else {
        content.push(U.getValue(value));
      }

      return content;
    };

    this.getRegistrantName = function (answers, blocks) {
      var answer = this.findAnswerByBlockType(answers, blocks, 'nameQuestion', 'NAME');

      return this.getContentByBlockType(U.isEmpty(answer) ? answer : answer.value, 'nameQuestion');
    };

    this.findAnswerByBlockType = function (answers, blocks, blockType, profileType) {
      var block = this.findBlockByType(blocks, blockType, profileType);
      if (!U.isEmpty(block)) {
        return this.findAnswerByBlockId(answers, block.id);
      }

      block = this.findBlockByType(blocks, blockType);
      if (!U.isEmpty(block)) {
        return this.findAnswerByBlockId(answers, block.id);
      }

      return null;
    };

    this.findBlockByType = function (blocks, blockType, profileType) {
      return _.find(blocks, function (block) {
        if (!U.isEmpty(profileType)) {
          return block.type === blockType && block.profileType === profileType;
        }

        return block.type === blockType && block.type;
      });
    };

    this.findAnswerByBlockId = function (answers, blockId) {
      return _.find(answers, function (answer) {
        return angular.equals(answer.blockId, blockId);
      });
    };

    this.getPageBlocks = function (pages) {
      var blocks = [];
      angular.forEach(pages, function (page) {
        angular.forEach(page.blocks, function (block) {
          if (block.type.indexOf('Content') === -1) {
            blocks.push(block);
          }
        });
      });

      return blocks;
    };

    this.hasCost = function (conference) {
      return conference.conferenceCost && conference.conferenceCost > 0;
    };
  });

{'fraction_non_alphanumeric': 0.144142896704514, 'fraction_numerical': 0.0011077263915812794, 'mean_word_length': 2.598903836571998, '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': '2352646', 'n_tokens_mistral': 2138, 'n_tokens_neox': 2061, 'n_words': 372}