<commit_before>(function () {

    _controller.$inject = ['TaskService', 'toastr', '$state', '$stateParams'];

    angular
        .module('projectTracker')
        .controller('taskListController', _controller);

    function _controller(TaskService, toastr, $state, $stateParams) {
        var self = this;

        self.createTask = _createTask;
        self.updateTask = _updateTask;
        self.deleteTask = _deleteTask;
        self.selectTask = _selectTask;

        self.newTask = {};
        self.initializing = true;

        _initList();

        function _initSearch(data) {
            var foundIds = self.searchIndex.search($stateParams.search)
                .map(function (doc) { return doc.ref; });
            return _(data).keyBy('id').at(foundIds).filter().value();
        }

        function _initList() {
            TaskService.getList().then(function (data) {
                self.selectedId = $stateParams.id;
                self.searchIndex = _initSearchIndex(data);
                if ($stateParams.search) {
                    self.tasks = _initSearch(data);
                }
                else {
                    self.tasks = data;
                }

                self.initializing = false;
            });
        }

        function _createTask() {
            if (!self.newTask.title)
                return;

            self.loading = true;

            return TaskService.create(self.newTask)
                .then(function (task) {
                    //                    self.tasks.push(task);
                    _initList();
                    toastr.info('Task ' + self.newTask.title + ' created!');
                    self.searchIndex.add(task);
                    self.newTask = {};
                })
                .finally(function () {
                    self.loading = false;
                });
        }

        function _updateTask(task) {
            self.loading = true;<commit_msg>Fix in task list initialization<commit_after>(function () {

    _controller.$inject = ['TaskService', 'toastr', '$state', '$stateParams'];

    angular
        .module('projectTracker')
        .controller('taskListController', _controller);

    function _controller(TaskService, toastr, $state, $stateParams) {
        var self = this;

        self.createTask = _createTask;
        self.updateTask = _updateTask;
        self.deleteTask = _deleteTask;
        self.selectTask = _selectTask;

        self.newTask = {};
        self.initializing = true;

        _initList();

        function _initSearch(data) {
            var foundIds = self.searchIndex.search($stateParams.search)
                .map(function (doc) { return doc.ref; });
            return _(data).keyBy('id').at(foundIds).filter().value();
        }

        function _initList() {
            TaskService.getList().then(function (data) {
                self.selectedId = $stateParams.id;
                self.searchIndex = _initSearchIndex(data);
                if ($stateParams.search) {
                    self.tasks = _initSearch(data);
                }
                else {
                    self.tasks = data;
                }

                self.initializing = false;
            });
        }

        function _createTask() {
            if (!self.newTask.title)
                return;

            self.loading = true;

            return TaskService.create(self.newTask)
                .then(function (task) {
                    //_initList();
                    self.selectedId = $stateParams.id;
                    TaskService.getList().then(function (data) {
                        self.tasks = data;
                    });
                    toastr.info('Task ' + self.newTask.title + ' created!');
                    self.searchIndex.add(task);
                    self.newTask = {};
                })
                .finally(function () {
                    self.loading = false;
                });
        }

        function _updateTask(task) {
            self.loading = true;
{'fraction_non_alphanumeric': 0.11544153922052294, 'fraction_numerical': 0.0, 'mean_word_length': 1.3838918283362729, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6633470', 'n_tokens_mistral': 1061, 'n_tokens_neox': 991, 'n_words': 174}