<commit_before>/**
 * CountryService provides access to information about countries.
 */
define([
  'Class',
  'uri',
  'bluebird',  
  'map/services/DataService'
], function (Class, UriTemplate, Promise, ds) {

  'use strict';

  var GET_REQUEST_ID = 'CountryService:get',
      SHOW_REQUEST_ID = 'CountryService:show';

  var URL = window.gfw.config.GFW_API_HOST + '/countries/{id}';


  var CountryService = Class.extend({

    get: function() {
      return new Promise(function(resolve, reject) {

        var url = new UriTemplate(URL).fillFromObject({});

        ds.define(GET_REQUEST_ID, {
          cache: {type: 'persist', duration: 1, unit: 'days'},
          url: url,
          type: 'GET'
        });

        var requestConfig = {
          resourceId: GET_REQUEST_ID,
          success: resolve
        };

        ds.request(requestConfig);

      });
    },

    show: function(id) {
      return new Promise(function(resolve, reject) {

        var url = new UriTemplate(URL).fillFromObject({id: id});

        ds.define(SHOW_REQUEST_ID, {
          cache: {type: 'persist', duration: 1, unit: 'days'},
          url: url,
          type: 'GET',
          dataType: 'json',
          contentType: 'application/json; charset=utf-8',          

          // TO-DO We should move this to the DataService
          decoder: function ( data, status, xhr, success, error ) {
            if ( status === "success" ) {
              success( data, xhr );
            } else if ( status === "fail" || status === "error" ) {
              error( JSON.parse(xhr.responseText) );
            } else if ( status === "abort") {
              
            } else {
              error( JSON.parse(xhr.responseText) );
            }
          }          

        });

        var requestConfig = {
          resourceId: SHOW_REQUEST_ID,
          success: function(data, status) {
            resolve(data,status);        
          },
          error: function(errors) {
            reject(errors);
          }
        };

        ds.request(requestConfig);

      }.bind(this));
    },

  });

  var service = new CountryService();

  return service;
});
<commit_msg>Only store those countries that has ISO different from null<commit_after>/**
 * CountryService provides access to information about countries.
 */
define([
  'Class',
  'uri',
  'bluebird',  
  'map/services/DataService'
], function (Class, UriTemplate, Promise, ds) {

  'use strict';

  var GET_REQUEST_ID = 'CountryService:get',
      SHOW_REQUEST_ID = 'CountryService:show';

  var URL = window.gfw.config.GFW_API_HOST + '/countries/{id}';


  var CountryService = Class.extend({

    get: function() {
      return new Promise(function(resolve, reject) {

        var url = new UriTemplate(URL).fillFromObject({});

        ds.define(GET_REQUEST_ID, {
          cache: {type: 'persist', duration: 1, unit: 'days'},
          url: url,
          type: 'GET',
          dataType: 'json',
          contentType: 'application/json; charset=utf-8',          

          decoder: function ( data, status, xhr, success, error ) {
            if ( status === "success" ) {
              data.countries = _.filter(data.countries, function(country){
                return country.iso !== null
              });
              success( data, xhr );
            } else if ( status === "fail" || status === "error" ) {
              error( JSON.parse(xhr.responseText) );
            } else if ( status === "abort") {
              
            } else {
              error( JSON.parse(xhr.responseText) );
            }
          }          

        });

        var requestConfig = {
          resourceId: GET_REQUEST_ID,
          success: function(data, status) {
            resolve(data,status);        
          },
          error: function(errors) {
            reject(errors);
          }
        };

        ds.request(requestConfig);

      });
    },

    show: function(id) {
      return new Promise(function(resolve, reject) {

        var url = new UriTemplate(URL).fillFromObject({id: id});

        ds.define(SHOW_REQUEST_ID, {
          cache: {type: 'persist', duration: 1, unit: 'days'},
          url: url,
          type: 'GET',
          dataType: 'json',
          contentType: 'application/json; charset=utf-8',          

          // TO-DO We should move this to the DataService
          decoder: function ( data, status, xhr, success, error ) {
            if ( status === "success" ) {
              success( data, xhr );
            } else if ( status === "fail" || status === "error" ) {
              error( JSON.parse(xhr.responseText) );
            } else if ( status === "abort") {
              
            } else {
              error( JSON.parse(xhr.responseText) );
            }
          }          

        });

        var requestConfig = {
          resourceId: SHOW_REQUEST_ID,
          success: function(data, status) {
            resolve(data,status);        
          },
          error: function(errors) {
            reject(errors);
          }
        };

        ds.request(requestConfig);

      }.bind(this));
    },

  });

  var service = new CountryService();

  return service;
});

{'fraction_non_alphanumeric': 0.1330521472392638, 'fraction_numerical': 0.0013420245398773007, 'mean_word_length': 1.7129485179407176, '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': '3014077', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1434, 'n_words': 341}