<commit_before>function ddg_spice_amazon(api_response) {
    "use strict";

    if (!api_response || !api_response.results ||
	!api_response.results.length || api_response.results.length == 0) {
	return;
    }

    var items = api_result.results;

    // TODO: this is obviously not ideal, just ported over
    // what was in permenant.js. It loads ratings data for each item,
    // the render the spice plugin:
    var loadRatingsData = function(items,fn){
        var numLeft = items.length;

        var onGotRatingsData = function(r,s,x){
            // add the ratings data:
            this.ratingData = r;

            // add the products_buy template
            // TODO: this is hacky, can it combine with the Spice.templates?
            this.products_buy = DDG.templates.products_amazon_buy;

            // decrement the numLeft and
            // see if all have returned yet:
            numLeft--;
            if(!numLeft){
                // if done, call the callback:
                fn();
            }
        }

        for(var i=0;i<items.length;i++){
            var item = items[i],
                arg = item.rating,
                url = '/m.js?r=';

            arg = arg.replace(/(?:.com.au|.com.br|.cn|.fr|.de|.in|.it|.co.jp|.mx|.es|.co.uk|.com|.ca?)/i, '');
            arg = arg.replace('http://www.amazon/reviews/iframe?', '');
            $.getJSON(url + encodeURIComponent(arg),onGotRatingsData.bind(item));
        }
    };

    // loading ratings data for all the items
    // then render the spice:
    loadRatingsData(items,function(){
        Spice.add({
            id: 'products',
            name: 'Products',

            data: items,

            meta: {
                count: items.length,
                total: items.length,
                itemType: 'Products',
                sourceName: 'Amazon',
                sourceUrl: apiResult.more_at,
                sourceIcon: true
            },

            templates: {
                item: DDG.templates.products_item,
                detail: DDG.templates.products_detail,
                item_detail: DDG.templates.products_item_detail
            }
        });
    });
}<commit_msg>amazon.js: rename apiResult to api_response<commit_after>function ddg_spice_amazon(api_response) {
    "use strict";

    if (!api_response || !api_response.results ||
	!api_response.results.length || api_response.results.length == 0) {
	return;
    }

    var items = api_response.results;

    // TODO: this is obviously not ideal, just ported over
    // what was in permenant.js. It loads ratings data for each item,
    // the render the spice plugin:
    var loadRatingsData = function(items,fn){
        var numLeft = items.length;

        var onGotRatingsData = function(r,s,x){
            // add the ratings data:
            this.ratingData = r;

            // add the products_buy template
            // TODO: this is hacky, can it combine with the Spice.templates?
            this.products_buy = DDG.templates.products_amazon_buy;

            // decrement the numLeft and
            // see if all have returned yet:
            numLeft--;
            if(!numLeft){
                // if done, call the callback:
                fn();
            }
        }

        for(var i=0;i<items.length;i++){
            var item = items[i],
                arg = item.rating,
                url = '/m.js?r=';

            arg = arg.replace(/(?:.com.au|.com.br|.cn|.fr|.de|.in|.it|.co.jp|.mx|.es|.co.uk|.com|.ca?)/i, '');
            arg = arg.replace('http://www.amazon/reviews/iframe?', '');
            $.getJSON(url + encodeURIComponent(arg),onGotRatingsData.bind(item));
        }
    };

    // loading ratings data for all the items
    // then render the spice:
    loadRatingsData(items,function(){
        Spice.add({
            id: 'products',
            name: 'Products',

            data: items,

            meta: {
                count: items.length,
                total: items.length,
                itemType: 'Products',
                sourceName: 'Amazon',
                sourceUrl: api_response.more_at,
                sourceIcon: true
            },

            templates: {
                item: DDG.templates.products_item,
                detail: DDG.templates.products_detail,
                item_detail: DDG.templates.products_item_detail
            }
        });
    });
}
{'fraction_non_alphanumeric': 0.12111589929689272, 'fraction_numerical': 0.0009072352007257881, 'mean_word_length': 1.5971731448763251, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4094572', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1246, 'n_words': 288}