<commit_before>(function () {
    'use strict';

    angular
        .module('yamcs.events')
        .controller('EventsController',  EventsController);

    /* @ngInject */
    function EventsController($rootScope, $scope, $log, eventsService) {
        var vm = this;
        eventsService.resetUnreadCount(); // Poor man's solution

        $rootScope.pageTitle = 'Events | Yamcs';

        $scope.ctx = {
            loadingMoreData: false
        };

        $scope.loadMoreEvents = function() {
            if (!vm.events.length || $scope.ctx.loadingMoreData) return;
            $scope.ctx.loadingMoreData = true;

            var finalEvent = vm.events[vm.events.length - 1];
            console.log('loading more data from ' + finalEvent['generationTimeUTC']);

            eventsService.listEvents({
                limit: 20,
                stop: finalEvent['generationTimeUTC']
            }).then(function (data) { // todo check when end is reached, to prevent further triggers
                vm.events.push.apply(vm.events, data);
                $scope.ctx.loadingMoreData = false;
                return vm.events;
            });
        };


        vm.events = [];
        eventsService.listEvents().then(function (data) {
            vm.events = data;
            return vm.events;
        });

        $rootScope.$on('yamcs.eventStats', function(evt, stats) {
            vm.stats = stats;
        });

        vm.reloadData = function() {
            eventsService.resetUnreadCount(); // Not waterproof
            eventsService.listEvents({
                limit: 200
            }).then(function (data) {
                vm.events = data;
                return vm.events;
            });
        };

        vm.severityToggles = {
            info: true,
            warning: true,
            error: true
        };

        vm.searchText = '';
        vm.filterTable = function(event) {
            var severityMatch = false;
            if (event['severity'] === 'INFO') {<commit_msg>Prevent errors on empty event list<commit_after>(function () {
    'use strict';

    angular
        .module('yamcs.events')
        .controller('EventsController',  EventsController);

    /* @ngInject */
    function EventsController($rootScope, $scope, $log, eventsService) {
        var vm = this;
        eventsService.resetUnreadCount(); // Poor man's solution

        $rootScope.pageTitle = 'Events | Yamcs';

        $scope.ctx = {
            loadingMoreData: false
        };

        $scope.loadMoreEvents = function() {
            if (!vm.events.length || $scope.ctx.loadingMoreData) return;
            $scope.ctx.loadingMoreData = true;

            var finalEvent = vm.events[vm.events.length - 1];
            console.log('loading more data from ' + finalEvent['generationTimeUTC']);

            eventsService.listEvents({
                limit: 20,
                stop: finalEvent['generationTimeUTC']
            }).then(function (data) { // todo check when end is reached, to prevent further triggers
                vm.events.push.apply(vm.events, data);
                $scope.ctx.loadingMoreData = false;
                return vm.events;
            });
        };


        vm.events = [];
        eventsService.listEvents().then(function (data) {
            vm.events = data || [];
            return vm.events;
        });

        $rootScope.$on('yamcs.eventStats', function(evt, stats) {
            vm.stats = stats;
        });

        vm.reloadData = function() {
            eventsService.resetUnreadCount(); // Not waterproof
            eventsService.listEvents({
                limit: 200
            }).then(function (data) {
                vm.events = data || [];
                return vm.events;
            });
        };

        vm.severityToggles = {
            info: true,
            warning: true,
            error: true
        };

        vm.searchText = '';
        vm.filterTable = function(event) {
            var severityMatch = false;
            if (event['severity'] === 'INFO') {
{'fraction_non_alphanumeric': 0.12312238364934745, 'fraction_numerical': 0.002954937207584339, 'mean_word_length': 1.6308290155440415, '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': '6422271', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1032, 'n_words': 221}