<commit_before>'use strict';

mldsApp.factory('CountryService', ['$http', '$log', '$q', function($http, $log, $q){
		return {
			getCountries: function() {
				return $q.when([
					{
						isoCode2: 'DK',
						isoCode3: 'DNK',
						commonName: 'Denmark'
					},
					{
						isoCode2: 'FR',
						isoCode3: 'FRA',
						commonName: 'France'
					},
					{
						isoCode2: 'UA',
						isoCode3: 'URE',
						commonName: 'United Arab Emirates'
					},
					{
						isoCode2: 'GB',
						isoCode3: 'GBP',
						commonName: 'United Kingdom'
					},
					{
						isoCode2: 'US',
						isoCode3: 'USA',
						commonName: 'United States'
					}
				]);
				//FIXME retrieve countries from server
				//return $http.get('/app/countries');
			},
		};
		
	}]);<commit_msg>Replace placeholder countries with real service call<commit_after>'use strict';

mldsApp.factory('CountryService', ['$http', '$log', '$q', function($http, $log, $q){
	
		var countriesListQ = $http.get('/app/rest/countries')
			.then(function(d){return d.data;});
		var service = {};
		
		service.countries = [];
		service.countriesByCode = {};
		
		service.getCountries = function getCountries() {
			return countriesListQ;
		};
		
		countriesListQ.then(function(countries){
			// append to countries list
			Array.prototype.push.apply(service.countries,countries);
			
			// fill countriesByCode map
			service.countries.map(function(c){
				service.countriesByCode[c.isoCode2] = c;
			});
			
			$log.log('CountryService', service);
		});
		
		return service;
		
	}]);
{'fraction_non_alphanumeric': 0.16677524429967427, 'fraction_numerical': 0.0071661237785016286, 'mean_word_length': 2.764705882352941, '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': '2645840', 'n_tokens_mistral': 700, 'n_tokens_neox': 509, 'n_words': 100}