<commit_before>(function () {
    'use strict';

    angular
        .module('eliteApp')
        .factory('eliteApi', ['$http', '$q', '$ionicLoading',  eliteApi])
    function eliteApi($http, $q, $ionicLoading) {
        var currentLeagueId;

        function getLeagues() {
            var deferred = $q.defer();
            $ionicLoading.show({template: 'Loading...'});
            $http
                .get("http://elite-schedule.net/api/leaguedata")
                .success(function(data) {
                    $ionicLoading.hide();
                    deferred.resolve(data);
                })
                .error(function() {
                    $ionicLoading.hide();
                    console.log("Error while making HTTP call.");
                    deferred.reject();
                });
            return deferred.promise;
        }

        function getLeagueData() {
            var deferred = $q.defer();
            $ionicLoading.show({template: 'Loading...'});
            $http
                .get("http://elite-schedule.net/api/leaguedata/" + currentLeagueId)
                .success(function(data, status) {
                    $ionicLoading.hide();
                    console.log("Received schedule data via HTTP.", data, status);
                    deferred.resolve(data);
                })
                .error(function() {
                    $ionicLoading.hide();
                    console.log("Error while making HTTP call.");
                    deferred.reject();
                });
            return deferred.promise;
        }

        function setLeagueId(leagueId) {<commit_msg>implementing caches<commit_after>(function () {
    'use strict';

    angular
        .module('eliteApp')
        .factory('eliteApi', ['$http', '$q', '$ionicLoading', 'CacheFactory', eliteApi])
    function eliteApi($http, $q, $ionicLoading, CacheFactory) {
        var currentLeagueId;

        self.leaguesCache = CacheFactory.get("leaguesCache");
        self.leagueDataCache = CacheFactory.get("leagueDataCache");

        function getLeagues() {
            var deferred = $q.defer();
            var cacheKey = 'leagues';
            var leaguesData = self.leaguesCache.get(cacheKey);

            if(leaguesData) {
                console.log("Found data inside cache", leaguesData);
                deferred.resolve(leaguesData);
            } else {
                $ionicLoading.show({template: 'Loading...'});
                $http
                    .get("http://elite-schedule.net/api/leaguedata")
                    .success(function(data) {
                        $ionicLoading.hide();
                        console.log("Received data via HTTP");
                        self.leaguesCache.put(cacheKey, data);
                        deferred.resolve(data);
                    })
                    .error(function() {
                        $ionicLoading.hide();
                        console.log("Error while making HTTP call.");
                        deferred.reject();
                    });
            }

            return deferred.promise;
        }

        function getLeagueData() {
            var deferred = $q.defer();
            var cacheKey = 'leagueData-' + currentLeagueId;
            var leagueData = self.leagueDataCache.get(cacheKey);

            if(leagueData) {
                console.log("Found data in cache", leagueData);
                deferred.resolve(leagueData);
            } else {
                $ionicLoading.show({template: 'Loading...'});
                $http
                    .get("http://elite-schedule.net/api/leaguedata/" + currentLeagueId)
                    .success(function(data, status) {
                        $ionicLoading.hide();
                        console.log("Received schedule data via HTTP.", data, status);
                        self.leagueDataCache.put(cacheKey, data);
                        deferred.resolve(data);
                    })
                    .error(function() {
                        $ionicLoading.hide();
                        console.log("Error while making HTTP call.");
                        deferred.reject();
                    });
            }
            return deferred.promise;
        }

        function setLeagueId(leagueId) {
{'fraction_non_alphanumeric': 0.12191717077710564, 'fraction_numerical': 0.0, 'mean_word_length': 1.3376835236541598, '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': '3097411', 'n_tokens_mistral': 1100, 'n_tokens_neox': 991, 'n_words': 186}