<commit_before>angular.module('huntEdu.services')
    .service('SearchService', ['$http', '$q', '_', 'JobList', 'User',  
    function searchService($http, $q, _, JobList, User) {

        var forEach = _.forEach,
            isEmpty = _.isEmpty;

        /**
         * Populate JobList service with jobs containing keyword, then
         * return the results. 
         * @param keyword {String} search keyword
         * @param limit {Integer} max number of results
         * @return [Job1, Job2, ...]
         */

        this.search = function(keyword, limit) {
            var deferred = $q.defer();

            limit = limit || 100;

            if(JobList.hasResults(keyword)) {
                deferred.resolve(JobList.getResults(keyword));
                return deferred.promise;  
            }
             
            $http.get('/search' + '/' + keyword)
                .then(function(res) {
                    var jobPostsRaw = res.data,
                        count = 0;
                    forEach(jobPostsRaw, function(jobPostRaw){
                        if(count < limit) {
                            JobList.addJob(jobPostRaw, keyword);
                        }
                        count += 1;
                    });
                    
                    deferred.resolve(JobList.getResults(keyword));
                }, function(err) {<commit_msg>not caching job results for now<commit_after>angular.module('huntEdu.services')
    .service('SearchService', ['$http', '$q', '_', 'JobList', 'User',  
    function searchService($http, $q, _, JobList, User) {

        var forEach = _.forEach,
            isEmpty = _.isEmpty;

        /**
         * Populate JobList service with jobs containing keyword, then
         * return the results. 
         * @param keyword {String} search keyword
         * @param limit {Integer} max number of results
         * @return [Job1, Job2, ...]
         */

        this.search = function(keyword, limit) {
            var deferred = $q.defer();

            limit = limit || 100;

            $http.get('/search' + '/' + keyword)
                .then(function(res) {
                    var jobPostsRaw = res.data,
                        count = 0;
                    forEach(jobPostsRaw, function(jobPostRaw){
                        if(count < limit) {
                            JobList.addJob(jobPostRaw, keyword);
                        }
                        count += 1;
                    });
                    
                    deferred.resolve(JobList.getResults(keyword));
                }, function(err) {
{'fraction_non_alphanumeric': 0.1165644171779141, 'fraction_numerical': 0.005368098159509203, 'mean_word_length': 1.3170515097690942, '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': '1453720', 'n_tokens_mistral': 688, 'n_tokens_neox': 629, 'n_words': 147}