<commit_before>module.exports = (function(){
	
var twitterRequestDef = require('q').defer();

function collectParams(url) {
		var helper = require("../../helpers");
		var params = helper.paramsForUrl(url);
		params.time = helper.unixToDate(params.time);
		return params
	}

	function createInstance(searchInfo) {
		var Twitter = require('node-twitter');
		return new Twitter.SearchClient( 
			process.env.CONSUMER_KEY, 
			process.env.CONSUMER_SECRET, 
			process.env.ACCESS_TOKEN_KEY, 
			process.env.ACCESS_TOKEN_SECRET 
		);
	}

	function locationForTweet(tweet) {
		try {
			return {
				"lat": tweet.geo.coordinates.shift(),
				"lon": tweet.geo.coordinates.shift()
			}
		} catch(e) {
			return {
				"lat": "", // TODO: Make current search coords
				"lon": ""  // TODO: Make current search coords
			}
		}
	}

	function hashtagsForTweet(tweet) {
		try {
			return tweet.entities.hashtags.map(function(hashtag) {
				return hashtag.text;
			});
		} catch(e) {
			return [];
		}
	}

	function granualFromTweet(tweet) {
		return granual = {
			type: 				"text",
			created_at: 	tweet.created_at,
			source: 			"twitter",
			language: 		tweet.lang,
			content: 			tweet.text,
			author:     	tweet.user.screen_name,
			location:   	locationForTweet(tweet),
			hashtags:   	hashtagsForTweet(tweet)
		}
	}

	function granualsFromTwitterData(twitterData) {
		return twitterData.map(function(tweet) {
			return granualFromTweet(tweet);
		});
	}

	function requestData(err, data) {
		twitterRequestDef.resolve(data.statuses);
	}

	return TwitterManager = {
		search: function *(url) {
			var params = collectParams(url);
			var Twitter = createInstance();
			
			Twitter.search( { 
				'q': '',
				'geocode': params.lat + "," + params.lng + "," + "1mi", 
				'since_id': params.time,
				'result_type': 'recent',
				'count': 100,
				'include_entities': true }, 
				requestData)

			return twitterRequestDef.promise
			.then(granualsFromTwitterData);
		}
	};
})();<commit_msg>Fix twitter unix time input.<commit_after>module.exports = (function(){
	
var twitterRequestDef = require('q').defer();

function collectParams(url) {
		var helper = require("../../helpers");
		var params = helper.paramsForUrl(url);
		params.time = helper.unixToDate(params.time + '000');
		return params
	}

	function createInstance(searchInfo) {
		var Twitter = require('node-twitter');
		return new Twitter.SearchClient( 
			process.env.CONSUMER_KEY, 
			process.env.CONSUMER_SECRET, 
			process.env.ACCESS_TOKEN_KEY, 
			process.env.ACCESS_TOKEN_SECRET 
		);
	}

	function locationForTweet(tweet) {
		try {
			return {
				"lat": tweet.geo.coordinates.shift(),
				"lon": tweet.geo.coordinates.shift()
			}
		} catch(e) {
			return {
				"lat": "", // TODO: Make current search coords
				"lon": ""  // TODO: Make current search coords
			}
		}
	}

	function hashtagsForTweet(tweet) {
		try {
			return tweet.entities.hashtags.map(function(hashtag) {
				return hashtag.text;
			});
		} catch(e) {
			return [];
		}
	}

	function granualFromTweet(tweet) {
		return granual = {
			type: 				"text",
			created_at: 	tweet.created_at,
			source: 			"twitter",
			language: 		tweet.lang,
			content: 			tweet.text,
			author:     	tweet.user.screen_name,
			location:   	locationForTweet(tweet),
			hashtags:   	hashtagsForTweet(tweet)
		}
	}

	function granualsFromTwitterData(twitterData) {
		return twitterData.map(function(tweet) {
			return granualFromTweet(tweet);
		});
	}

	function requestData(err, data) {
		twitterRequestDef.resolve(data.statuses);
	}

	return TwitterManager = {
		search: function *(url) {
			var params = collectParams(url);
			var Twitter = createInstance();
			
			Twitter.search( { 
				'q': '',
				'geocode': params.lat + "," + params.lng + "," + "1mi", 
				'since_id': params.time,
				'result_type': 'recent',
				'count': 100,
				'include_entities': true }, 
				requestData)
			console.log(params);
			return twitterRequestDef.promise
			.then(granualsFromTwitterData);
		}
	};
})();
{'fraction_non_alphanumeric': 0.1424287856071964, 'fraction_numerical': 0.002748625687156422, 'mean_word_length': 3.3322510822510822, 'pattern_counts': {'":': 8, '<': 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': '94639', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1414, 'n_words': 244}