<commit_before>/*
 * Copyright 2016 e-UCM (http://www.e-ucm.es/)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * This project has received funding from the European Union’s Horizon
 * 2020 research and innovation programme under grant agreement No 644187.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0 (link is external)
 *
 * 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.
 */

'use strict';

angular.module('classApp', ['ngStorage', 'services'])
    .controller('ClassCtrl', ['$scope', '$location', '$http', '$window', '$localStorage', 'Games', 'Versions', 'Sessions', 'Role', 'CONSTANTS', 'QueryParams',
        function ($scope, $location, $http, $window, $localStorage, Games, Versions, Sessions, Role, CONSTANTS, QueryParams) {
            $scope.$storage = $localStorage;
            $scope.session = {};
            $scope.class = {};

            var getSessions = function () {
                $http.get(CONSTANTS.PROXY + '/games/' + QueryParams.getQueryParam('game') + '/versions/' +
                    QueryParams.getQueryParam('version') + '/sessions/my').success(function (data) {
                    $scope.sessions = data;
                }).error(function (data, status) {
                    console.error('Error on get /games/' + QueryParams.getQueryParam('game') + '/versions/' +
                        QueryParams.getQueryParam('version') + '/sessions/my' + JSON.stringify(data) + ', status: ' + status);
                });
            };

            getSessions();
            $scope.gameId = QueryParams.getQueryParam('game');
            $scope.versionId = QueryParams.getQueryParam('version');
            $scope.loading = false;

            $scope.createSession = function () {
                var className = $scope.class.name ? $scope.class.name : 'New class';
                $http.post(CONSTANTS.PROXY + '/games/' + QueryParams.getQueryParam('game') + '/versions/' +
                    QueryParams.getQueryParam('version') + '/sessions', {name: className}).success(function (session) {

                        $http.get(CONSTANTS.PROXY + '/kibana/visualization/list/' + $scope.gameId)
                            .success(function(data) {

                                var panels = [];
                                var uiStates = {};

                                // Add index
                                $http.post(CONSTANTS.PROXY + '/kibana/index/' + $scope.gameId + '/' + session._id, {})
                                    .success(function(data) {

                                    }).error(function (data, status) {
                                    console.error('Error on post /kibana/index/' + $scope.gameId + '/' + session._id + ' ' +
                                        JSON.stringify(data) + ', status: ' + status);
                                });

                                // Add dashboard
                                var numPan = 1;
                                data.forEach(function (visualizationId) {
                                    $http.post(CONSTANTS.PROXY + '/kibana/visualization/session/' + visualizationId + '/' + session._id, {})
                                        .success(function(result) {
                                            panels.push('{\"id\":\"' + visualizationId + '_' + session._id +
                                                '\",\"type\":\"visualization\",\"panelIndex\":' + numPan + ',' +
                                                '\"size_x\":3,\"size_y\":2,\"col\":1,\"row\":' + numPan + '}');
                                            uiStates['P-' + numPan] = {vis: {legendOpen: false}};
                                            numPan++;

                                            if (numPan > data.length) {
                                                var dashboard = {
                                                    title: 'dashboard_' + session._id,
                                                    hits: 0,<commit_msg>Fixed route<commit_after>/*
 * Copyright 2016 e-UCM (http://www.e-ucm.es/)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * This project has received funding from the European Union’s Horizon
 * 2020 research and innovation programme under grant agreement No 644187.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0 (link is external)
 *
 * 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.
 */

'use strict';

angular.module('classApp', ['ngStorage', 'services'])
    .controller('ClassCtrl', ['$scope', '$location', '$http', '$window', '$localStorage', 'Games', 'Versions', 'Sessions', 'Role', 'CONSTANTS', 'QueryParams',
        function ($scope, $location, $http, $window, $localStorage, Games, Versions, Sessions, Role, CONSTANTS, QueryParams) {
            $scope.$storage = $localStorage;
            $scope.session = {};
            $scope.class = {};

            var getSessions = function () {
                $http.get(CONSTANTS.PROXY + '/games/' + QueryParams.getQueryParam('game') + '/versions/' +
                    QueryParams.getQueryParam('version') + '/sessions/my').success(function (data) {
                    $scope.sessions = data;
                }).error(function (data, status) {
                    console.error('Error on get /games/' + QueryParams.getQueryParam('game') + '/versions/' +
                        QueryParams.getQueryParam('version') + '/sessions/my' + JSON.stringify(data) + ', status: ' + status);
                });
            };

            getSessions();
            $scope.gameId = QueryParams.getQueryParam('game');
            $scope.versionId = QueryParams.getQueryParam('version');
            $scope.loading = false;

            $scope.createSession = function () {
                var className = $scope.class.name ? $scope.class.name : 'New class';
                $http.post(CONSTANTS.PROXY + '/games/' + QueryParams.getQueryParam('game') + '/versions/' +
                    QueryParams.getQueryParam('version') + '/sessions', {name: className}).success(function (session) {

                        $http.get(CONSTANTS.PROXY + '/kibana/visualization/list/' + $scope.gameId)
                            .success(function(data) {

                                var panels = [];
                                var uiStates = {};

                                // Add index
                                $http.post(CONSTANTS.PROXY + '/kibana/index/' + $scope.gameId + '/' + session._id, {})
                                    .success(function(data) {

                                    }).error(function (data, status) {
                                    console.error('Error on post /kibana/index/' + $scope.gameId + '/' + session._id + ' ' +
                                        JSON.stringify(data) + ', status: ' + status);
                                });

                                // Add dashboard
                                var numPan = 1;
                                data.forEach(function (visualizationId) {
                                    $http.post(CONSTANTS.PROXY + '/kibana/visualization/session/' + $scope.gameId + '/' + visualizationId + '/' + session._id,
                                        {}).success(function(result) {
                                            panels.push('{\"id\":\"' + visualizationId + '_' + session._id +
                                                '\",\"type\":\"visualization\",\"panelIndex\":' + numPan + ',' +
                                                '\"size_x\":3,\"size_y\":2,\"col\":1,\"row\":' + numPan + '}');
                                            uiStates['P-' + numPan] = {vis: {legendOpen: false}};
                                            numPan++;

                                            if (numPan > data.length) {
                                                var dashboard = {
                                                    title: 'dashboard_' + session._id,
                                                    hits: 0,
{'fraction_non_alphanumeric': 0.13269121813031162, 'fraction_numerical': 0.005212464589235128, 'mean_word_length': 1.442845280929975, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 58, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6593314', 'n_tokens_mistral': 2165, 'n_tokens_neox': 2055, 'n_words': 503}