<commit_before>//
// Service to allow the common pattern of copying an episode to a different
// categrory.
// 
angular.module('opal.services')
    .factory('CopyToCategory', function($http, $q){
        
        // 
        // Main entrypoint function for service
        //
        // When given an episode and a category, we return a deferred
        // that resolves with a new episode, with all details preserved
        // apart from teams (blank) and category (CATEGORY)
        // 
        var CopyToCategory = function(episode_id, category){
            var deferred = $q.defer();
            $http.post('/episode/' + episode_id + '/actions/copyto/'+category).then(
                function(response){ // Success
                    deferred.resolve(response.data);
                },
                function(response){ // Error
                    alert('Unable to create a new episode in ' + category);
                }
            );
            return deferred.promise;
        }
        
        return CopyToCategory;
    });
<commit_msg>CopyToCategory resolves with an episode instance. refs openhealthcare/elcid#544<commit_after>//
// Service to allow the common pattern of copying an episode to a different
// categrory.
// 
angular.module('opal.services')
    .factory('CopyToCategory', function($http, $q, Episode){
        
        // 
        // Main entrypoint function for service
        //
        // When given an episode and a category, we return a deferred
        // that resolves with a new episode, with all details preserved
        // apart from teams (blank) and category (CATEGORY)
        // 
        var CopyToCategory = function(episode_id, category){
            var deferred = $q.defer();
            $http.post('/episode/' + episode_id + '/actions/copyto/'+category).then(
                function(response){ // Success
                    deferred.resolve(new Episode(response.data));
                },
                function(response){ // Error
                    alert('Unable to create a new episode in ' + category);
                }
            );
            return deferred.promise;
        }
        
        return CopyToCategory;
    });

{'fraction_non_alphanumeric': 0.10373066424021839, 'fraction_numerical': 0.001364877161055505, 'mean_word_length': 1.6817073170731707, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6979798', 'n_tokens_mistral': 563, 'n_tokens_neox': 529, 'n_words': 167}