<commit_before>function FilterValue(key, value, isSelected) {
    var filterValue = this;
    this.ui_id = key + "_" + value.id;
    this.id = value.id;
    this.selected = ko.observable(isSelected);
    this.en = value.names.en;
    this.de = value.names.de;
    this.displayName = function () {
        return filterValue[languageUtils.selectedLanguage()];
    };
};

function TalkListViewModel() {
    // Data
    var self = this;

    self.groupedTalks = ko.observableArray([]);
    self.allTalks = [];
    self.metaData = {};

    self.filters = [
        {title: ko.observable(''), filterKey: 'level', filtervalues : ko.observableArray([])},
        {title: ko.observable(''), filterKey: 'language', filtervalues : ko.observableArray([])},
        {title: ko.observable(''), filterKey: 'track', filtervalues : ko.observableArray([])},
        {title: ko.observable(''), filterKey: 'location', filtervalues : ko.observableArray([])}
    ];

    self.days = ko.observableArray([]);
    self.selectedDayIndex = ko.observable(dukeconSettings.getSelectedDay());
    self.selectedDay = "";

    self.onlyFavourites = ko.observable(dukeconSettings.favoritesActive());
    self.filtersActive = ko.observable(dukeconSettings.filtersActive());

    //temporarily pause filter update actions
    self.updateFiltersPaused = false;

    self.onlyFavourites.subscribe(function(val) {
        dukeconSettings.saveSetting(dukeconSettings.favs_active, self.onlyFavourites());
        self.filterTalks();
    });

    self.filtersActive.subscribe(function(val) {
        self.toggleFilterMenu(self.filtersActive());
        dukeconSettings.saveSetting(dukeconSettings.filter_active_key, self.filtersActive());
        self.filterTalks();
    });

    languageUtils.selectedLanguage.subscribe(function(language) {
        self.initializeFilters(self.metaData);
    });

    self.initialize = function(allData) {
        var favourites = dukeconSettings.getFavourites();
        var mappedTalks = $.map(allData.events, function(talk) {
            return new Talk(talk, allData.speakers, allData.metaData, favourites.indexOf(talk.id) !== -1)
        }).sort(self.sortTalk);
        self.metaData = allData.metaData;
        self.allTalks = mappedTalks;
        self.initializeDays();
        self.initializeFilters(allData.metaData);
        self.filterTalks();
        self.toggleFilterMenu(self.filtersActive());
        hideLoading(200);
    };

    self.updateFavourites = function() {
        var favourites = dukeconSettings.getFavourites();
        _.each(self.allTalks, function(talk) {
            talk.favourite(favourites.indexOf(talk.id) !== -1);
        });
        self.filterTalks();
    };

    // Functions
    self.sortTalk = function(t1, t2) {<commit_msg>#30: Only re-filter talks if something changed<commit_after>function FilterValue(key, value, isSelected) {
    var filterValue = this;
    this.ui_id = key + "_" + value.id;
    this.id = value.id;
    this.selected = ko.observable(isSelected);
    this.en = value.names.en;
    this.de = value.names.de;
    this.displayName = function () {
        return filterValue[languageUtils.selectedLanguage()];
    };
};

function TalkListViewModel() {
    // Data
    var self = this;

    self.groupedTalks = ko.observableArray([]);
    self.allTalks = [];
    self.metaData = {};

    self.filters = [
        {title: ko.observable(''), filterKey: 'level', filtervalues : ko.observableArray([])},
        {title: ko.observable(''), filterKey: 'language', filtervalues : ko.observableArray([])},
        {title: ko.observable(''), filterKey: 'track', filtervalues : ko.observableArray([])},
        {title: ko.observable(''), filterKey: 'location', filtervalues : ko.observableArray([])}
    ];

    self.days = ko.observableArray([]);
    self.selectedDayIndex = ko.observable(dukeconSettings.getSelectedDay());
    self.selectedDay = "";

    self.onlyFavourites = ko.observable(dukeconSettings.favoritesActive());
    self.filtersActive = ko.observable(dukeconSettings.filtersActive());

    //temporarily pause filter update actions
    self.updateFiltersPaused = false;

    self.onlyFavourites.subscribe(function(val) {
        dukeconSettings.saveSetting(dukeconSettings.favs_active, self.onlyFavourites());
        self.filterTalks();
    });

    self.filtersActive.subscribe(function(val) {
        self.toggleFilterMenu(self.filtersActive());
        dukeconSettings.saveSetting(dukeconSettings.filter_active_key, self.filtersActive());
        self.filterTalks();
    });

    languageUtils.selectedLanguage.subscribe(function(language) {
        self.initializeFilters(self.metaData);
    });

    self.initialize = function(allData) {
        var favourites = dukeconSettings.getFavourites();
        var mappedTalks = $.map(allData.events, function(talk) {
            return new Talk(talk, allData.speakers, allData.metaData, favourites.indexOf(talk.id) !== -1)
        }).sort(self.sortTalk);
        self.metaData = allData.metaData;
        self.allTalks = mappedTalks;
        self.initializeDays();
        self.initializeFilters(allData.metaData);
        self.filterTalks();
        self.toggleFilterMenu(self.filtersActive());
        hideLoading(200);
    };

    self.updateFavourites = function() {
        var favourites = dukeconSettings.getFavourites();
        var favouritesChanged = false;
        _.each(self.allTalks, function(talk) {
            var isFavourite = favourites.indexOf(talk.id) !== -1;
            if (!favouritesChanged && talk.favourite() != isFavourite) {
                favouritesChanged = true;
            }
            talk.favourite(isFavourite);
        });
        if (favouritesChanged) {
            self.filterTalks();
        }
    };

    // Functions
    self.sortTalk = function(t1, t2) {
{'fraction_non_alphanumeric': 0.13887454827052143, 'fraction_numerical': 0.002753398726553089, 'mean_word_length': 3.1103253182461104, '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': '114427', 'n_tokens_mistral': 1789, 'n_tokens_neox': 1714, 'n_words': 268}