<commit_before>'use strict';

angular.module('pitchfxApp').service('Filters', [ '$timeout', '$angularCacheFactory', function($timeout, $angularCacheFactory)
{
    var filterCache = $angularCacheFactory('pinnedFilters', {
        capacity : 100,
        storageMode : 'localStorage',
    });

    this.filters = {};
    this.pinnedFilters = [];

    /**
     * reloads all saved filters from storage
     */
    this.reloadSavedFilters = function()
    {
        this.pinnedFilters = [];
        var filterNames = filterCache.keys(), key;
        for (key in filterNames)
        {
            this.pinnedFilters.push(filterCache.get(key));
        }
    };

    /**
     * Pins a new filter. This is different than saveActiveFilter as it is done
     * on purpose.
     */
    this.pinFilter = function(filterName, filter)
    {
        var self = this;
        $timeout(function()
        {
            filter.name = filterName;
            filterCache.put(filterName, filter);
            self.reloadSavedFilters();
        });
    };

} ]);<commit_msg>#46: GA event for saving a filter<commit_after>'use strict';

angular.module('pitchfxApp').service('Filters', [ '$timeout', '$angularCacheFactory', function($timeout, $angularCacheFactory)
{
    var filterCache = $angularCacheFactory('pinnedFilters', {
        capacity : 100,
        storageMode : 'localStorage',
    });

    this.filters = {};
    this.pinnedFilters = [];

    /**
     * reloads all saved filters from storage
     */
    this.reloadSavedFilters = function()
    {
        this.pinnedFilters = [];
        var filterNames = filterCache.keys(), key;
        for (key in filterNames)
        {
            this.pinnedFilters.push(filterCache.get(key));
        }
    };

    /**
     * Pins a new filter. This is different than saveActiveFilter as it is done
     * on purpose.
     */
    this.pinFilter = function(filterName, filter)
    {
        var self = this;
        $timeout(function()
        {
            filter.name = filterName;
            filterCache.put(filterName, filter);
            self.reloadSavedFilters();
            _gaq.push([ '_trackEvent', 'filters', 'saved', filterName]);
        });
    };

} ]);
{'fraction_non_alphanumeric': 0.13118474807081254, 'fraction_numerical': 0.003631411711302769, 'mean_word_length': 2.226939970717423, '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': '2537266', 'n_tokens_mistral': 623, 'n_tokens_neox': 621, 'n_words': 133}