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

    angular
        .module('crowdsource.task.controllers')
        .controller('TaskOverviewController', TaskOverviewController);

    TaskOverviewController.$inject = ['$window', '$location', '$scope', '$mdToast', 'Task',
        '$filter', '$routeParams', 'Authentication', 'RankingService', '$rootScope'];

    /**
     * @namespace TaskOverviewController
     */
    function TaskOverviewController($window, $location, $scope, $mdToast, Task,
                               $filter, $routeParams, Authentication, RankingService, $rootScope) {
        var self = this;
        self.tasks = [];
        self.getStatusName = getStatusName;
        self.get_answer = get_answer;
        self.toggleAll = toggleAll;
        self.toggle = toggle;
        self.isSelected = isSelected;
        self.selectedItems = [];
        self.updateStatus = updateStatus;
        self.downloadResults = downloadResults;
        self.navigateToMyProjects = navigateToMyProjects;
        self.expand = expand;

        self.sort = sort;
        self.config = {
            order_by: "",
            order: ""
        };

        self.expandedRow = null;

        activate();

        function activate(){
            var project_id = $routeParams.projectId;
            getTasks(project_id);
        }

        function getTasks(project_id){
            Task.getTasks(project_id).then(
                function success(response) {
                    self.tasks = response[0].tasks;
                    self.project_name = response[0].project_name;
                    self.project_description = response[0].project_description;

                    getWorkerData(project_id);
                },
                function error(response) {
                    $mdToast.showSimple('Could not get tasks for project.');
                }
            ).finally(function () {});
        }

        function getStatusName (status) {
            if(status == 1) {
                return 'In Progress';
            }
            else if(status == 2){
                return 'Submitted';
            }
            else if(status == 3){
                return 'Accepted';
            }
            else if(status == 4){
                return 'Rejected';
            }
            else if(status == 5){
                return 'Returned';
            }
        }<commit_msg>Rating issue on task review<commit_after>(function () {
    'use strict';

    angular
        .module('crowdsource.task.controllers')
        .controller('TaskOverviewController', TaskOverviewController);

    TaskOverviewController.$inject = ['$window', '$location', '$scope', '$mdToast', 'Task',
        '$filter', '$routeParams', 'Authentication', 'RankingService', '$rootScope'];

    /**
     * @namespace TaskOverviewController
     */
    function TaskOverviewController($window, $location, $scope, $mdToast, Task,
                               $filter, $routeParams, Authentication, RankingService, $rootScope) {
        var self = this;
        self.tasks = [];
        self.getStatusName = getStatusName;
        self.get_answer = get_answer;
        self.toggleAll = toggleAll;
        self.toggle = toggle;
        self.isSelected = isSelected;
        self.selectedItems = [];
        self.updateStatus = updateStatus;
        self.downloadResults = downloadResults;
        self.navigateToMyProjects = navigateToMyProjects;
        self.expand = expand;
        self.handleRatingSubmit = handleRatingSubmit;

        self.sort = sort;
        self.config = {
            order_by: "",
            order: ""
        };

        self.expandedRow = null;

        activate();

        function activate(){
            var project_id = $routeParams.projectId;
            getTasks(project_id);
        }

        function getTasks(project_id){
            Task.getTasks(project_id).then(
                function success(response) {
                    self.tasks = response[0].tasks;
                    self.project_name = response[0].project_name;
                    self.project_description = response[0].project_description;

                    getWorkerData(project_id);
                },
                function error(response) {
                    $mdToast.showSimple('Could not get tasks for project.');
                }
            ).finally(function () {});
        }

        function getWorkerData(project_id) {
            self.workerRankings = [];
            self.rankings = {};
            self.loadingRankings = true;

            RankingService.getWorkerRankingsByProject(project_id).then(
                function success(resp) {
                    var data = resp[0];
                    data = data.map(function (item) {
                        item.reviewType = 'requester';

                        if(item.hasOwnProperty('id') && item.id){
                            item.current_rating_id=item.id;
                        }

                        if(item.hasOwnProperty('weight') && item.weight){
                            item.current_rating=item.weight;
                        }

                        // attach to task based on worker alias
                        self.rankings[item.alias] = item;

                        return item;
                    });

                    self.workerRankings = data;

                },
                function error(resp) {
                    var data = resp[0];
                    $mdToast.showSimple('Could not get worker rankings.');
                }).finally(function(){
                    self.loadingRankings = false;
                });
        }

        function handleRatingSubmit(rating, entry) {
            if (entry && entry.hasOwnProperty('current_rating_id') && entry.current_rating_id) {
                RankingService.updateRating(rating, entry).then(function success(resp) {
                    entry.current_rating = rating;
                }, function error(resp) {
                    $mdToast.showSimple('Could not update rating.');
                }).finally(function () {

                });
            } else {
                RankingService.submitRating(rating, entry).then(function success(resp) {
                    entry.current_rating_id = resp[0].id;
                    entry.current_rating = rating;
                }, function error(resp) {
                    $mdToast.showSimple('Could not submit rating.')
                }).finally(function () {

                });
            }

        }

        function getStatusName (status) {
            if(status == 1) {
                return 'In Progress';
            }
            else if(status == 2){
                return 'Submitted';
            }
            else if(status == 3){
                return 'Accepted';
            }
            else if(status == 4){
                return 'Rejected';
            }
            else if(status == 5){
                return 'Returned';
            }
        }
{'fraction_non_alphanumeric': 0.1073978863181948, 'fraction_numerical': 0.002713510425592688, 'mean_word_length': 1.460646521433591, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6435923', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1654, 'n_words': 323}