<commit_before>'use strict';

var _ = require('lodash');
var fmt = require('simple-fmt');
var cheerio = require('cheerio');
var req = require('../lib/request.js');
var items = [];

module.exports = function (app) {
	app.service('NewlyService', function ($q, FilterItemsFactory, ItemDataFactory, UserDetailsService) {

		function get (deferred, settings) {
			var user = UserDetailsService.get();
			req(fmt('http://steamcommunity.com/market/recent?country={0}&language={1}&currency={2}', user.country, user.language, user.currency))
				.then(function (response) {
					var body = response.getBody();
					var $ = cheerio.load('<div>' + body.results_html + '</div>');
					var data = [];

					$('.market_listing_row').each(function(i, elem) {
					  var item = ItemDataFactory($(this));
					  data.push(item);
					});

					// Reduce to only uniq intems
					items = _.uniq(data.concat(items), function (i) {
						return i.id;
					});

					console.log(items);

					// Filter items according to our settings
					items = FilterItemsFactory.filter(items, settings.game, settings.items);


					deferred.resolve(items);

				}, deferred.reject);
		}

		return {

			get: function (settings) {
				var deferred = $q.defer();
				get(deferred, settings);
				return deferred.promise;
			},

			cache: function () {
				return items;
			},

			clearCache: function () {
				items = [];
			}

		};
	});
};
<commit_msg>newly service cleanup<commit_after>'use strict';

var _ = require('lodash');
var fmt = require('simple-fmt');
var cheerio = require('cheerio');
var req = require('../lib/request.js');
var items = [];

module.exports = function (app) {
	app.service('NewlyService', function ($q, FilterItemsFactory, ItemDataFactory, UserDetailsService) {

		function get (deferred, settings) {
			var user = UserDetailsService.get();
			req(fmt('http://steamcommunity.com/market/recent?country={0}&language={1}&currency={2}', user.country, user.language, user.currency))
				.then(function (response) {
					var body = response.getBody();
					var $ = cheerio.load('<div>' + body.results_html + '</div>');
					var data = [];

					$('.market_listing_row').each(function(i, elem) {
					  var item = ItemDataFactory($(this));
					  data.push(item);
					});

					// Reduce to only uniq intems
					items = _.uniq(data.concat(items), function (i) {
						return i.id;
					});

					// Filter items according to our settings
					items = FilterItemsFactory.filter(items, settings.game, settings.items);
					deferred.resolve(items);
				}, deferred.reject);
		}

		return {

			get: function (settings) {
				var deferred = $q.defer();
				get(deferred, settings);
				return deferred.promise;
			},

			cache: function () {
				return items;
			},

			clearCache: function () {
				items = [];
			}

		};
	});
};

{'fraction_non_alphanumeric': 0.16767317939609236, 'fraction_numerical': 0.0021314387211367673, 'mean_word_length': 3.2282282282282284, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2183432', 'n_tokens_mistral': 1100, 'n_tokens_neox': 862, 'n_words': 189}