<commit_before>angular.module('gateways', [])
.factory('gateways', function($http) {
    var original     = null;
    var userGateways = store.get('gateways');
  
    var promise = $http.get(API + '/gateways').success(function (data) {
      original = data;
      
      if (!userGateways) {
        userGateways = original;
        for (var currency in userGateways) {
          for (var i in userGateways[currency]) {
            if (userGateways[currency][i].featured) {
              userGateways[currency][i].selected = true;
            }
          }
        }
      }
    });
  
    var getCurrencies = function () {
      var currencies = [];
      currencies.push({
        currency  : "XRP",
        icon      : API + '/currencies/xrp.svg'
      });
      for (var currency in userGateways) {
        for (var i=0; i<userGateways[currency].length; i++) {
          if (userGateways[currency][i].selected === true) {
            currencies.push({
              currency : currency,
              icon     : API + '/currencies/'+ currency +'.svg'
            });
            break;
          }
        }
      }
      
      return currencies;
    };
  
    var getIssuers = function (currency, options) {
      var issuers = [ ];
      var normalized;
      
      if (!options) options = { };
      
      if (!userGateways[currency]) {
        return issuers;
      }
      
      for (var i in userGateways[currency]) {
        if (options.all || userGateways[currency][i].selected === true) {
          normalized = userGateways[currency][i].name.toLowerCase().replace(/\W/g, '');
          issuers.push({
            name     : userGateways[currency][i].name,
            account  : userGateways[currency][i].account,
            icon     : API + '/gateways/' + normalized + '/assets/logo.svg',
            featured : userGateways[currency][i].featured,
            selected : userGateways[currency][i].selected
          });
        }
      }
      
      return issuers;
    };

    return {
      promise       : promise,
      getCurrencies : getCurrencies,
      getIssuers    : getIssuers
    }
});<commit_msg>add assets field to gateway objects<commit_after>angular.module('gateways', [])
.factory('gateways', function($http) {
    var original     = null;
    var userGateways = store.get('gateways');

    var promise = $http.get(API + '/gateways').success(function (data) {
      original = data;

      if (!userGateways) {
        userGateways = original;
        for (var currency in userGateways) {
          for (var i in userGateways[currency]) {
            if (userGateways[currency][i].featured) {
              userGateways[currency][i].selected = true;
            }
          }
        }
      }
    });

    var getCurrencies = function () {
      var currencies = [];
      currencies.push({
        currency  : "XRP",
        icon      : API + '/currencies/xrp.svg'
      });
      for (var currency in userGateways) {
        for (var i=0; i<userGateways[currency].length; i++) {
          if (userGateways[currency][i].selected === true) {
            currencies.push({
              currency : currency,
              icon     : API + '/currencies/'+ currency +'.svg'
            });
            break;
          }
        }
      }

      return currencies;
    };

    var getIssuers = function (currency, options) {
      var issuers = [ ];
      var normalized;
      var assets;

      if (!options) options = { };

      if (!userGateways[currency]) {
        return issuers;
      }

      for (var i in userGateways[currency]) {
        if (options.all || userGateways[currency][i].selected === true) {
          normalized = userGateways[currency][i].name.toLowerCase().replace(/\W/g, '');
          assets = handleAssets(userGateways[currency][i].assets, normalized);

          issuers.push({
            name     : userGateways[currency][i].name,
            account  : userGateways[currency][i].account,
            icon     : API + '/gateways/' + normalized + '/assets/logo.svg',
            assets   : assets,
            featured : userGateways[currency][i].featured,
            selected : userGateways[currency][i].selected
          });
        }
      }

      return issuers;

      //add API endpoint to asset filenames
      function handleAssets(assets, normalized) {
        var obj = { };

        if (!assets) assets = [ ];

        assets.forEach(function(a) {
          obj[a] = API + '/gateways/' + normalized + '/assets/' + a;
        });

        return obj;
      }
    };

    return {
      promise       : promise,
      getCurrencies : getCurrencies,
      getIssuers    : getIssuers
    }
});
{'fraction_non_alphanumeric': 0.13310507168842287, 'fraction_numerical': 0.00042799058420714745, 'mean_word_length': 1.7656804733727811, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4475237', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1325, 'n_words': 273}