<commit_before>'use strict';

angular.module('mean.icu').config([
    '$meanStateProvider',
    function ($meanStateProvider) {
        var LIMIT = 25;
        var SORT = 'created';
        var BIGLIMIT = 2500;

        var capitalize = function (str) {
            return str.charAt(0).toUpperCase() + str.slice(1);
        };

        var generateStateByEntity = function (main) {
            var capitalizedMain = capitalize(main);

            var resolve = {};
            resolve[main + 's'] = [capitalizedMain + 'sService', '$stateParams',
            function (service, $stateParams) {
                if($stateParams.officeDocuments){
                    return $stateParams.officeDocuments;
                }
                else{
                var getFn = 'getBy' + capitalize($stateParams.entity) + 'Id';
                if (!service[getFn]) {
                    getFn = 'getById';
                }
                if (service.IsNew) {
                    return service[getFn]($stateParams.entityId,
                        $stateParams.start,
                        BIGLIMIT,
                        $stateParams.sort,
                        $stateParams.starred);
                }
                else {
                    return service[getFn]($stateParams.entityId,
                        $stateParams.start,
                        $stateParams.limit,
                        $stateParams.sort,
                        $stateParams.status,
                        $stateParams.starred);
                }
            }
            }
            ];

            resolve.entity = ['context',
                function (context) {
                    return context.entity;
                }
            ];
            if (main !== 'task') {
                resolve.tasks = function (TasksService, $stateParams) {
                    if ($stateParams.entityId && $stateParams.id) {
                        return;
                    }
                    var getFn = 'getBy' + capitalize($stateParams.entity) + 'Id';
                    return TasksService[getFn]($stateParams.entityId);
                };
            }

            return {
                url: '/by-:entity/:entityId',
                params: {
                    starred: false,
                    start: 0,
                    limit: LIMIT,
                    sort: SORT,
                    status:undefined,
                },
                views: {
                    'middlepane@main': {
                        templateUrl: '/icu/components/entity-list/entity-list.html',
                        controller: capitalizedMain + 'ListController'
                    },
                    'detailspane@main': {
                        templateUrl: function ($stateParams) {
                            if (!$stateParams.entity) return '';
                            else return '/icu/components/' + $stateParams.entity + '-details/' +
                                $stateParams.entity + '-details.html';
                        },
                        controllerProvider: function ($stateParams) {
                            if (!$stateParams.entity) return '';
                            else return capitalize($stateParams.entity) + 'DetailsController';
                        }
                    }
                },
                resolve: resolve
            }
        };

        var getListView = function (entity, resolve) {
            var view = {
                'middlepane@main': {
                    templateUrl: '/icu/components/entity-list/entity-list.html',
                    controller: capitalize(entity) + 'ListController'
                },
                'detailspane@main': {
                    templateUrl: '/icu/components/all/all.html',
                    controller: 'AllController'
                }
            };


            if (resolve) {
                view['middlepane@main'].resolve = resolve;
            }
            return view;
        };

        function getTaskDetailsState(urlPrefix) {
            if (!urlPrefix) {
                urlPrefix = '';
            }

            return {
                url: urlPrefix + '/:id',
                views: {
                    'detailspane@main': {
                        templateUrl: '/icu/components/task-details/task-details.html',
                        controller: 'TaskDetailsController'
                    },
//                     'subtasks@main': {
//                         templateUrl: '/icu/components/sub-tasks/sub-tasks.html',
//                         controller: 'SubTasksController'
//                     }
                },
                params: {
                    nameFocused: false
                },
                resolve: {
                    entity: function (tasks, $stateParams, TasksService) {
                        var task = _(tasks.data || tasks).find(function (t) {
                            return t._id === $stateParams.id;
                        });
                        return TasksService.getStarred()
                            .then(starred => {
                                if($stateParams.starred){
                                    tasks.data = tasks.data.filter( task => _.includes(getArrIds(starred), task._id) );
                                }
                                if (!task) {
                                    return TasksService.getById($stateParams.id).then(function (task) {
                                        return task;<commit_msg>added check to filter by start tasks<commit_after>'use strict';

angular.module('mean.icu').config([
    '$meanStateProvider',
    function ($meanStateProvider) {
        var LIMIT = 25;
        var SORT = 'created';
        var BIGLIMIT = 2500;

        var capitalize = function (str) {
            return str.charAt(0).toUpperCase() + str.slice(1);
        };

        var generateStateByEntity = function (main) {
            var capitalizedMain = capitalize(main);

            var resolve = {};
            resolve[main + 's'] = [capitalizedMain + 'sService', '$stateParams',
            function (service, $stateParams) {
                if($stateParams.officeDocuments){
                    return $stateParams.officeDocuments;
                }
                else{
                var getFn = 'getBy' + capitalize($stateParams.entity) + 'Id';
                if (!service[getFn]) {
                    getFn = 'getById';
                }
                if (service.IsNew) {
                    return service[getFn]($stateParams.entityId,
                        $stateParams.start,
                        BIGLIMIT,
                        $stateParams.sort,
                        $stateParams.starred);
                }
                else {
                    return service[getFn]($stateParams.entityId,
                        $stateParams.start,
                        $stateParams.limit,
                        $stateParams.sort,
                        $stateParams.status,
                        $stateParams.starred);
                }
            }
            }
            ];

            resolve.entity = ['context',
                function (context) {
                    return context.entity;
                }
            ];
            if (main !== 'task') {
                resolve.tasks = function (TasksService, $stateParams) {
                    if ($stateParams.entityId && $stateParams.id) {
                        return;
                    }
                    var getFn = 'getBy' + capitalize($stateParams.entity) + 'Id';
                    return TasksService[getFn]($stateParams.entityId);
                };
            }

            return {
                url: '/by-:entity/:entityId',
                params: {
                    starred: false,
                    start: 0,
                    limit: LIMIT,
                    sort: SORT,
                    status:undefined,
                },
                views: {
                    'middlepane@main': {
                        templateUrl: '/icu/components/entity-list/entity-list.html',
                        controller: capitalizedMain + 'ListController'
                    },
                    'detailspane@main': {
                        templateUrl: function ($stateParams) {
                            if (!$stateParams.entity) return '';
                            else return '/icu/components/' + $stateParams.entity + '-details/' +
                                $stateParams.entity + '-details.html';
                        },
                        controllerProvider: function ($stateParams) {
                            if (!$stateParams.entity) return '';
                            else return capitalize($stateParams.entity) + 'DetailsController';
                        }
                    }
                },
                resolve: resolve
            }
        };

        var getListView = function (entity, resolve) {
            var view = {
                'middlepane@main': {
                    templateUrl: '/icu/components/entity-list/entity-list.html',
                    controller: capitalize(entity) + 'ListController'
                },
                'detailspane@main': {
                    templateUrl: '/icu/components/all/all.html',
                    controller: 'AllController'
                }
            };


            if (resolve) {
                view['middlepane@main'].resolve = resolve;
            }
            return view;
        };

        function getTaskDetailsState(urlPrefix) {
            if (!urlPrefix) {
                urlPrefix = '';
            }

            return {
                url: urlPrefix + '/:id',
                views: {
                    'detailspane@main': {
                        templateUrl: '/icu/components/task-details/task-details.html',
                        controller: 'TaskDetailsController'
                    },
//                     'subtasks@main': {
//                         templateUrl: '/icu/components/sub-tasks/sub-tasks.html',
//                         controller: 'SubTasksController'
//                     }
                },
                params: {
                    nameFocused: false
                },
                resolve: {
                    entity: function (tasks, $stateParams, TasksService) {
                        var task = _(tasks.data || tasks).find(function (t) {
                            return t._id === $stateParams.id;
                        });
                        return TasksService.getStarred()
                            .then(starred => {
                                if($stateParams.starred){
                                    let tasksArr = tasks.data || tasks;
                                    tasksArr = tasksArr.filter( task => _.includes(getArrIds(starred), task._id) );
                                }
                                if (!task) {
                                    return TasksService.getById($stateParams.id).then(function (task) {
                                        return task;
{'fraction_non_alphanumeric': 0.10101100474188064, 'fraction_numerical': 0.0016104500313143062, 'mean_word_length': 0.9603647842862154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3089240', 'n_tokens_mistral': 2617, 'n_tokens_neox': 2412, 'n_words': 439}