<commit_before>'use strict';

(function(module) {

let tweets = {};
tweets.filteredTweets = [];
tweets.all = [];


// constructor for filteredTweets that adds objects of tweets with useful properties
function TweetObject(name, content, location, photo, time, hashtags) {
  this.userName = name;
  this.content = content;
  this.location = location;
  this.photo = photo;
  this.time = time;
  this.hashtags = hashtags;
}

tweets.getTweets = function (screen) {
  tweets.filteredTweets = [];
  $.ajax(`/map?search=${screen}`, {
    method: 'GET'
  })
    .then((result) => {
      console.log('about to log: result');
      console.log(result);
      console.log('just logged result');


      result.map(function (ele) {
        tweets.all.push(ele);
      })
      // calling a function to filter tweets by whether or not a location is defined and populating tweets.filteredTweets.
      tweets.tweetsWitIt();
      tweets.all = [];
      mapTweets.initMap();
    })
    .catch(console.error);
}

// filters returned tweets by whether or not they have coordinates attached
tweets.tweetsWitIt = function () {
  tweets.all.forEach(function (a) {
    console.log('logging: a.place in tweetsWitIt');
    console.log(a.place);

    if (a.place !== null && a.place.hasOwnProperty('bounding_box')) {
      console.log('in elseif');
      // below is the list of desired properties of returned tweets, run through the TweetObject contructor and pushed into filteredTweets
      tweets.filteredTweets.push(a = new TweetObject(
        a.user.name,
        a.text,
        a.place.bounding_box.coordinates[0][0],
        a.user.profile_image_url,
        a.created_at,
        a.entities.hashtags
      ));
    }
  })
}


module.tweets = tweets;
})(window);<commit_msg>fixed array clearing and returned filter function to previous state'<commit_after>'use strict';

(function(module) {

let tweets = {};
tweets.filteredTweets = [];
tweets.all = [];


// constructor for filteredTweets that adds objects of tweets with useful properties
function TweetObject(name, content, location, photo, time, hashtags) {
  this.userName = name;
  this.content = content;
  this.location = location;
  this.photo = photo;
  this.time = time;
  this.hashtags = hashtags;
}

tweets.getTweets = function (screen) {
  $.ajax(`/map?search=${screen}`, {
    method: 'GET'
  })
    .then((result) => {
      console.log(result);
      tweets.filteredTweets = [];

      result.map(function (ele) {
        tweets.all.push(ele);
      })
      // calling a function to filter tweets by whether or not a location is defined and populating tweets.filteredTweets.
      tweets.tweetsWitIt();
      tweets.all = [];
      mapTweets.initMap();
    })
    .catch(console.error);
}

// filters returned tweets by whether or not they have coordinates attached
tweets.tweetsWitIt = function () {
  tweets.all.forEach(function (a) {
    if (a.place === null) {
      // below is the list of desired properties of returned tweets, run through the TweetObject contructor and pushed into filteredTweets
    } else if (a.place.hasOwnProperty('bounding_box'))
      tweets.filteredTweets.push(a = new TweetObject(
        a.user.name,
        a.text,
        a.place.bounding_box.coordinates[0][0],
        a.user.profile_image_url,
        a.created_at,
        a.entities.hashtags
      ));
    })
}


module.tweets = tweets;
})(window);
{'fraction_non_alphanumeric': 0.12765330188679244, 'fraction_numerical': 0.0011792452830188679, 'mean_word_length': 3.0296912114014254, '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': '2465323', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1088, 'n_words': 264}