<commit_before>NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
    
    el: ".NB-module-river",
    
    events: {
        "click .NB-module-search-add-url"        : "add_url"
    },
    
    initialize: function () {
        var $dashboard_side = $(".NB-dashboard-rivers-" + this.model.get('river_side'));
        var $river_on_dashboard = $dashboard_side.find(".NB-dashboard-river-order-" + this.model.get('river_order'));
        var $river = this.template();
        if ($river_on_dashboard.length) {
            $river_on_dashboard.replaceWith($river);
        } else {
            $dashboard_side.append($river);
        }
        this.$el = $river;
        
        this.$stories = this.$(".NB-module-item .NB-story-titles");
        
        // console.log(['dashboard stories view', this.$stories, this.options, this.$stories.el]);
        
        this.story_titles = new NEWSBLUR.Views.StoryTitlesView({
            el: this.$stories.get(0),
            collection: this.options.dashboard_stories,
            $story_titles: this.$stories,
            override_layout: 'split',
            on_dashboard: this
        });
        this.page = 1;
        this.cache = {
            story_hashes: []
        };
        
        if (this.options.active_feed == "river:infrequent") {
            this.options.infrequent = NEWSBLUR.assets.preference('infrequent_stories_per_month');
        } else if (this.options.active_feed == "river:global") {
            this.options.global_feed = true;
        }

        NEWSBLUR.assets.feeds.bind('reset', _.bind(this.load_stories, this));
        NEWSBLUR.assets.stories.bind('change:read_status', this.check_read_stories, this);
        // NEWSBLUR.assets.stories.bind('change:selected', this.check_read_stories, this);
        
        this.setup_dashboard_refresh();
        this.load_stories();
    },

    template: function () {
        var $river = $(_.template('<div class="NB-module NB-module-river NB-dashboard-river">\
            <h5 class="NB-module-header">\
                <div class="NB-module-river-settings NB-javascript"></div>\
                <div class="NB-module-river-title"><%= river_title %></div>\
            </h5>\
            \
            <div class="NB-view-river">\
                <div class="NB-module-item NB-story-pane-west">\
                    <div class="NB-story-titles"></div>\
                </div>\
            </div>\
        </div>\
        ', {
            river_title: NEWSBLUR.reader.feed_title(this.model.get('river_id'))
        }));

        return $river;
    },

    options_template: function () {
        var $options = $(_.template('<div class="NB-feedbar-options-container">\
            <span class="NB-feedbar-options">\
                <div class="NB-icon"></div>\
                <%= NEWSBLUR.assets.view_setting(feed_id, "read_filter") %>\
                &middot;\
                <%= NEWSBLUR.assets.view_setting(feed_id, "order") %>\
            </span>\
        </div>'), {
            feed_id: this.options.active_feed
        });
        
        this.$(".NB-module-river-settings").html($options);
    },
    
    feeds: function() {
        var feeds;
        var visible_only = NEWSBLUR.assets.view_setting(this.options.active_feed, 'read_filter') == 'unread';
        if (visible_only) {
            feeds = _.pluck(this.options.active_folder.feeds_with_unreads(), 'id');
            if (!feeds.length) {
                feeds = this.options.active_folder.feed_ids_in_folder();
            }
        } else {
            feeds = this.options.active_folder.feed_ids_in_folder();
        }
        
        return feeds;
    },
    
    // ===========
    // = Refresh =
    // ===========
    
    setup_dashboard_refresh: function() {
        // if (NEWSBLUR.Globals.debug) return;
        
        // Reload dashboard graphs every N minutes.
        var reload_interval = NEWSBLUR.Globals.is_staff ? 60*1000 : 15*60*1000;
        // var reload_interval = 60*60*1000;
        // console.log(['setup_dashboard_refresh', this.refresh_interval]);
        <commit_msg>Don't refresh dashboard feeds in debug to better debug them.<commit_after>NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
    
    el: ".NB-module-river",
    
    events: {
        "click .NB-module-search-add-url"        : "add_url"
    },
    
    initialize: function () {
        var $dashboard_side = $(".NB-dashboard-rivers-" + this.model.get('river_side'));
        var $river_on_dashboard = $dashboard_side.find(".NB-dashboard-river-order-" + this.model.get('river_order'));
        var $river = this.template();
        if ($river_on_dashboard.length) {
            $river_on_dashboard.replaceWith($river);
        } else {
            $dashboard_side.append($river);
        }
        this.$el = $river;
        
        this.$stories = this.$(".NB-module-item .NB-story-titles");
        
        // console.log(['dashboard stories view', this.$stories, this.options, this.$stories.el]);
        
        this.story_titles = new NEWSBLUR.Views.StoryTitlesView({
            el: this.$stories.get(0),
            collection: this.options.dashboard_stories,
            $story_titles: this.$stories,
            override_layout: 'split',
            on_dashboard: this
        });
        this.page = 1;
        this.cache = {
            story_hashes: []
        };
        
        if (this.options.active_feed == "river:infrequent") {
            this.options.infrequent = NEWSBLUR.assets.preference('infrequent_stories_per_month');
        } else if (this.options.active_feed == "river:global") {
            this.options.global_feed = true;
        }

        NEWSBLUR.assets.feeds.bind('reset', _.bind(this.load_stories, this));
        NEWSBLUR.assets.stories.bind('change:read_status', this.check_read_stories, this);
        // NEWSBLUR.assets.stories.bind('change:selected', this.check_read_stories, this);
        
        this.setup_dashboard_refresh();
        this.load_stories();
    },

    template: function () {
        var $river = $(_.template('<div class="NB-module NB-module-river NB-dashboard-river">\
            <h5 class="NB-module-header">\
                <div class="NB-module-river-settings NB-javascript"></div>\
                <div class="NB-module-river-title"><%= river_title %></div>\
            </h5>\
            \
            <div class="NB-view-river">\
                <div class="NB-module-item NB-story-pane-west">\
                    <div class="NB-story-titles"></div>\
                </div>\
            </div>\
        </div>\
        ', {
            river_title: NEWSBLUR.reader.feed_title(this.model.get('river_id'))
        }));

        return $river;
    },

    options_template: function () {
        var $options = $(_.template('<div class="NB-feedbar-options-container">\
            <span class="NB-feedbar-options">\
                <div class="NB-icon"></div>\
                <%= NEWSBLUR.assets.view_setting(feed_id, "read_filter") %>\
                &middot;\
                <%= NEWSBLUR.assets.view_setting(feed_id, "order") %>\
            </span>\
        </div>'), {
            feed_id: this.options.active_feed
        });
        
        this.$(".NB-module-river-settings").html($options);
    },
    
    feeds: function() {
        var feeds;
        var visible_only = NEWSBLUR.assets.view_setting(this.options.active_feed, 'read_filter') == 'unread';
        if (visible_only) {
            feeds = _.pluck(this.options.active_folder.feeds_with_unreads(), 'id');
            if (!feeds.length) {
                feeds = this.options.active_folder.feed_ids_in_folder();
            }
        } else {
            feeds = this.options.active_folder.feed_ids_in_folder();
        }
        
        return feeds;
    },
    
    // ===========
    // = Refresh =
    // ===========
    
    setup_dashboard_refresh: function() {
        if (NEWSBLUR.Globals.debug) return;
        
        // Reload dashboard graphs every N minutes.
        var reload_interval = NEWSBLUR.Globals.is_staff ? 60*1000 : 15*60*1000;
        // var reload_interval = 60*60*1000;
        // console.log(['setup_dashboard_refresh', this.refresh_interval]);
        
{'fraction_non_alphanumeric': 0.1533041788143829, 'fraction_numerical': 0.006316812439261419, 'mean_word_length': 1.900986610288936, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, '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': '5317570', 'n_tokens_mistral': 2615, 'n_tokens_neox': 2487, 'n_words': 355}