<commit_before>'use strict';

var moment = require( 'moment' );
var remoteConfig = require( './remoteConfig' );
var shared = require( '../shared' );
var redisClient = shared.redisClient;
var env = shared.env;
var debug = shared.debug;

// all sessions sheet
var redisKey = 'megazord';
if( env.get( 'REDIS_PREFIX' ) ) {
  redisKey = env.get( 'REDIS_PREFIX' ) + ':' + redisKey;
}

/**
 * Returns public view of twitter handle for a facilitator
 * based on session privacy options
 *
 * @param  {String} handle          Twitter handle
 * @param  {String} privacyOptions  Privacy options
 * @return {String}                 Publicly safe string
 */
function facilitatorTwitter( handle, privacyOptions ) {
  // check if we should hide the handle
  if( /twitter/ig.test( privacyOptions ) ) {
    return '';
  }

  return handle;
}

/**
 * Return an array of facilitators for a session [internal]
 *
 * @param  {Object} session A session object
 * @return {Array}          Array of facilitators for public display
 */
function sessionFaclitiators( session ) {
  var facilitators = [];

  // deal w/ primary facilitator first (the person who submitted the form)
  facilitators.push({
    name: session.firstname + ' ' + session.surname,
    twitter: facilitatorTwitter( session.twitter, session.privacy )
  });

  // separate out remaining facilitators (if any)
  var additional = session.facilitators.split( '\n' );
  additional.forEach( function( facilitator ) {
    var twitterRegExp = /\B@[a-z0-9_-]+/ig; // matches a twitter handle

    // look for their twitter handle and separate that out from their name
    var twitter = facilitator.match( twitterRegExp ) || '';
    if( twitter ) {
      twitter = facilitatorTwitter( twitter[ 0 ], session.privacy );<commit_msg>fix for crash on no additional facilitators<commit_after>'use strict';

var moment = require( 'moment' );
var remoteConfig = require( './remoteConfig' );
var shared = require( '../shared' );
var redisClient = shared.redisClient;
var env = shared.env;
var debug = shared.debug;

// all sessions sheet
var redisKey = 'megazord';
if( env.get( 'REDIS_PREFIX' ) ) {
  redisKey = env.get( 'REDIS_PREFIX' ) + ':' + redisKey;
}

/**
 * Returns public view of twitter handle for a facilitator
 * based on session privacy options
 *
 * @param  {String} handle          Twitter handle
 * @param  {String} privacyOptions  Privacy options
 * @return {String}                 Publicly safe string
 */
function facilitatorTwitter( handle, privacyOptions ) {
  // check if we should hide the handle
  if( /twitter/ig.test( privacyOptions ) ) {
    return '';
  }

  return handle;
}

/**
 * Return an array of facilitators for a session [internal]
 *
 * @param  {Object} session A session object
 * @return {Array}          Array of facilitators for public display
 */
function sessionFaclitiators( session ) {
  var facilitators = [];

  // deal w/ primary facilitator first (the person who submitted the form)
  facilitators.push({
    name: session.firstname + ' ' + session.surname,
    twitter: facilitatorTwitter( session.twitter, session.privacy )
  });

  // separate out remaining facilitators (if any)
  var additional = session.facilitators;
  if( !additional ) {
    return facilitators;
  }
  additional.split( '\n' ).forEach( function( facilitator ) {
    var twitterRegExp = /\B@[a-z0-9_-]+/ig; // matches a twitter handle

    // look for their twitter handle and separate that out from their name
    var twitter = facilitator.match( twitterRegExp ) || '';
    if( twitter ) {
      twitter = facilitatorTwitter( twitter[ 0 ], session.privacy );
{'fraction_non_alphanumeric': 0.11686513431182498, 'fraction_numerical': 0.001661589587371919, 'mean_word_length': 3.3413461538461537, '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': '4961598', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1024, 'n_words': 355}