<commit_before>'use strict';

var querystring = require('querystring');
var prequest = require('prequest');
var utils = require('./utils');
var config = require('../config');
var clc = require('cli-color');

var blacklistGroups = config.meetupParams.blacklistGroups || [];
var blacklistWords = config.meetupParams.blacklistWords || [];
var blacklistRE = new RegExp(blacklistWords.join('|'), 'i');

function constructAddress(venue) {
  var address = '';

  if (venue) {
    address = [
      venue.name,
      ', ',
      venue.address_1 || '',
      (venue.address_2 ? ', ' + venue.address_2 : '')
    ].join('');
    address += address.indexOf(config.meetupParams.city) === -1 ? ', ' + config.meetupParams.city : '';
  } else {
    address = config.meetupParams.city;
  }

  return address;
}

function isValidGroup(row) {
  var isValidCountry = row.country === (config.meetupParams.country || row.country);
  var isValidText = blacklistWords.length === 0 || !(row.name.match(blacklistRE) || (row.description !== undefined && row.description.match(blacklistRE)));

  if (row.name && row.description) {
    isValidText = blacklistWords.length === 0 ? true : !(row.name.match(blacklistRE) || row.description.match(blacklistRE));
  } else {
    isValidText = false;
  }

  var isValidGroupId = !blacklistGroups.some(function(id) { return row.id === id });

  return isValidCountry && isValidText && isValidGroupId;
}

function normalizeGroupEvents(events, row) {
  var eventTime;
  var event = {};

  if (!row.hasOwnProperty('venue') || row.venue_visibility === 'members') {
    return events;
  }

  if (row.duration === undefined) {
    row.duration = 7200000
  }

  eventTime = utils.localTime(row.time);

  event = {
    id: row.id,
    name: row.name,
    description: utils.htmlStrip(row.description),
    location: constructAddress(row.venue),
    url: row.event_url,
    group_name: row.group.name,
    group_url: 'http://meetup.com/' + row.group.urlname,
    formatted_time: utils.formatLocalTime(row.time),
    start_time: eventTime.toISOString(),
    end_time: eventTime.add(row.duration, 'milliseconds').toISOString()
  }

  events.push(event);
  return events;
}

// getEventsByGroupIds returns an array of events
// for the provided groups.
function getEventsByGroupIds(groupIds) {<commit_msg>:bug: fix: remove paid events from meetup.com<commit_after>'use strict';

var querystring = require('querystring');
var prequest = require('prequest');
var utils = require('./utils');
var config = require('../config');
var clc = require('cli-color');

var blacklistGroups = config.meetupParams.blacklistGroups || [];
var blacklistWords = config.meetupParams.blacklistWords || [];
var blacklistRE = new RegExp(blacklistWords.join('|'), 'i');

function constructAddress(venue) {
  var address = '';

  if (venue) {
    address = [
      venue.name,
      ', ',
      venue.address_1 || '',
      (venue.address_2 ? ', ' + venue.address_2 : '')
    ].join('');
    address += address.indexOf(config.meetupParams.city) === -1 ? ', ' + config.meetupParams.city : '';
  } else {
    address = config.meetupParams.city;
  }

  return address;
}

function isValidGroup(row) {
  var isValidCountry = row.country === (config.meetupParams.country || row.country);
  var isValidText = blacklistWords.length === 0 || !(row.name.match(blacklistRE) || (row.description !== undefined && row.description.match(blacklistRE)));

  if (row.name && row.description) {
    isValidText = blacklistWords.length === 0 ? true : !(row.name.match(blacklistRE) || row.description.match(blacklistRE));
  } else {
    isValidText = false;
  }

  var isValidGroupId = !blacklistGroups.some(function(id) { return row.id === id });

  return isValidCountry && isValidText && isValidGroupId;
}

function isFree(event) {
  return !event.fee;
}

function normalizeGroupEvents(events, row) {

  var eventTime;
  var event = {};

  if (!isFree(row)) {
    return events;
  }

  if (!row.hasOwnProperty('venue') || row.venue_visibility === 'members') {
    return events;
  }

  if (row.duration === undefined) {
    row.duration = 7200000
  }

  eventTime = utils.localTime(row.time);

  event = {
    id: row.id,
    name: row.name,
    description: utils.htmlStrip(row.description),
    location: constructAddress(row.venue),
    url: row.event_url,
    group_name: row.group.name,
    group_url: 'http://meetup.com/' + row.group.urlname,
    formatted_time: utils.formatLocalTime(row.time),
    start_time: eventTime.toISOString(),
    end_time: eventTime.add(row.duration, 'milliseconds').toISOString()
  }

  events.push(event);
  return events;
}

// getEventsByGroupIds returns an array of events
// for the provided groups.
function getEventsByGroupIds(groupIds) {
{'fraction_non_alphanumeric': 0.1568172224567328, 'fraction_numerical': 0.005487547488391726, 'mean_word_length': 3.9159751037344397, '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': '3705154', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1502, 'n_words': 302}