<commit_before>/*
 * Copyright 2007-2014 University Of Southern California
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

/**
 * Created by dcbriggs on 7/14/14.
 */
define(["moment"],
    function (moment) {
        "use strict"

        var runDetailsController = function ($scope, $state, $stateParams, $http, $window) {
            $scope.alerts = [];
            $scope.getAlertIcon = function (status) {
                return (status == 'success') ? "text-success fa fa-check-circle" : "text-danger fa fa-exclamation-triangle";
            };
            $scope.closeAlert = function (index) {
                $scope.alerts.splice(index, 1);
            };

            $scope.inputDownload = $window.apiLinks.runs + "/" + $stateParams.name + "/input/";
            $scope.outputDownload = $window.apiLinks.runs + "/" + $stateParams.name + "/output/";


            $scope.getFormattedDate = function (dateString) {
                var createdOn = moment.utc(dateString).local();
                var s = createdOn.format('dddd MMMM DD, YYYY hh:mm:ss A');
                s += ' (' + createdOn.fromNow() + ')';
                return s;
            };

            $scope.GTFAR_S3_BUCKET = $window.GTFAR_S3_BUCKET;

            $scope.analyzeURL = $window.apiLinks.runs + "/" + $stateParams.name + $window.apiLinks.analyze;

            function getRun() {
                $http.get($window.apiLinks.runs + "/" + $stateParams.name).success(function (data) {
                    $scope.run = data;
                    $scope.run.emails = null;
                    if ($scope.run.email) {
                        $scope.run.emails = $scope.run.email.split(',');
                    }
                    // If the run was stopped then we don't need to get the status
                    if ($scope.run.status != 256) {
                        setTimeout(getStatus, 1500);

                    }
                    else {
                        getOutputFiles();
                        getErrorReport();
                    }
                }).error(function (data) {
                    console.error(data);
                });
            }

            function getStatus() {
                $http.get($window.apiLinks.runs + "/" + $stateParams.name + $window.apiLinks.status).success(function (data) {
                    if (statusChanged(data)) {
                        $scope.status = data;
                        $scope.progressStyle = {width: $scope.status.progress + '%'};

                        getOutputFiles();
                        if ($scope.status.failed) {
                            getErrorReport();
                        }
                        else {
                            clearErrorReport();
                        }<commit_msg>No error handling was being done when getting run info<commit_after>/*
 * Copyright 2007-2014 University Of Southern California
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

/**
 * Created by dcbriggs on 7/14/14.
 */
define(["moment"],
    function (moment) {
        "use strict"

        var runDetailsController = function ($scope, $state, $stateParams, $http, $window) {
            $scope.alerts = [];
            $scope.getAlertIcon = function (status) {
                return (status == 'success') ? "text-success fa fa-check-circle" : "text-danger fa fa-exclamation-triangle";
            };
            $scope.closeAlert = function (index) {
                $scope.alerts.splice(index, 1);
            };

            $scope.inputDownload = $window.apiLinks.runs + "/" + $stateParams.name + "/input/";
            $scope.outputDownload = $window.apiLinks.runs + "/" + $stateParams.name + "/output/";


            $scope.getFormattedDate = function (dateString) {
                var createdOn = moment.utc(dateString).local();
                var s = createdOn.format('dddd MMMM DD, YYYY hh:mm:ss A');
                s += ' (' + createdOn.fromNow() + ')';
                return s;
            };

            $scope.GTFAR_S3_BUCKET = $window.GTFAR_S3_BUCKET;

            $scope.analyzeURL = $window.apiLinks.runs + "/" + $stateParams.name + $window.apiLinks.analyze;

            function getRun() {
                $http.get($window.apiLinks.runs + "/" + $stateParams.name).success(function (data) {
                    $scope.run = data;
                    $scope.run.emails = null;
                    if ($scope.run.email) {
                        $scope.run.emails = $scope.run.email.split(',');
                    }
                    // If the run was stopped then we don't need to get the status
                    if ($scope.run.status != 256) {
                        setTimeout(getStatus, 1500);

                    }
                    else {
                        getOutputFiles();
                        getErrorReport();
                    }
                }).error(function (data, status) {

                    if (status == 404) {
                        $scope.alerts.push({
                            'message': '404: Page Not Found. Please ensure that the URL is valid.',
                            'type': 'danger'
                        });

                        return;
                    }

                    console.log("Status: " + status +  "Data: " + data);
                });
            }

            function getStatus() {
                $http.get($window.apiLinks.runs + "/" + $stateParams.name + $window.apiLinks.status).success(function (data) {
                    if (statusChanged(data)) {
                        $scope.status = data;
                        $scope.progressStyle = {width: $scope.status.progress + '%'};

                        getOutputFiles();
                        if ($scope.status.failed) {
                            getErrorReport();
                        }
                        else {
                            clearErrorReport();
                        }
{'fraction_non_alphanumeric': 0.1163589523400601, 'fraction_numerical': 0.008587376556462, 'mean_word_length': 1.4467787114845938, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7318834', 'n_tokens_mistral': 1887, 'n_tokens_neox': 1751, 'n_words': 450}