<commit_before>'use strict';

/**
 */
angular.module('openolitor-admin')
  .controller('ReportsDetailController', ['$scope', '$rootScope', '$filter', '$routeParams',
    '$location', '$uibModal', 'gettext', 'ReportsModel', '$log', 'NgTableParams', 'lodash',
    function($scope, $rootScope, $filter, $routeParams, $location, $uibModal, gettext, ReportsModel, $log, NgTableParams, lodash) {
      $rootScope.viewId = 'D-Rept';

      $scope.isModifying = false;

      $scope.result = {
        entries: []
      }
      $scope.cols = [];

      var defaults = {
        model: {
          id: undefined
        }
      };

      $scope.search = {
        query: ''
      };

      if (!$routeParams.id || $routeParams.id === 'new') {
        $scope.isModifying = true;
        $scope.report = new ReportsModel(defaults.model);
      } else {
        ReportsModel.get({
          id: $routeParams.id
        }, function(result) {
          result.query = sqlFormatter.format(result.query);
          $scope.report = result;
        });
      }

      $scope.isExisting = function() {
        return angular.isDefined($scope.report) && angular.isDefined($scope.report.id);
      };

      $scope.renderedInput = function($scope, row) {
        if (row[this.field] !== null) {
          if (/kundeid|kunde_id|kunde-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/kunden/' + row[this.field] + '">' + row[this.field] + '</a>';
          } else if (/zusatz-abo-id|zusatz_abo_id|zusatzaboid|zusatzabo_id|zusatzabo-id/.test(this.field.toLowerCase())) {
            return row[this.field];
          } else if (/abotypid|abotyp_id|abotyp-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/abotypen/' + row[this.field] + '>' + row[this.field] + '</a>';
          } else if (/aboid|abo_id|abo-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/abos/q=id%3D' + row[this.field] + '&f=%7B\'zusatzAbosAktiv\':true%7D&tf=%7B\'abotypId\':\'\',\'aktiv\':true%7D">' + row[this.field] + '</a>';
          } else if (/tourid|tour_id|tour-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/touren/' + row[this.field] + '>' + row[this.field] + '</a>';
          } else if (/depotid|depot_id|depot-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/depots/' + row[this.field] + '>' + row[this.field] + '</a>';
          } else if (/produzentid|produzent_id|produzent-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/produzenten/' + row[this.field] + '">' + row[this.field] + '</a>';
          } else {
            return row[this.field];
          }
        }
        return row[this.field];
      };

      $scope.renderedTitles = function(key) {
        if (key !== null) {
          if (/kundeid|kunde_id|kunde-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/kunden?q=id%3D' + uniqueItems + '&tf=%7B%22typen%22:%22%22%7D">' + key + '</a></b>';
          } else if (/zusatz-abo-id|zusatz_abo_id|zusatzaboid|zusatzabo_id|zusatzabo-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/zusatzabos?q=id%3D' + uniqueItems + '&f=%7B\'zusatzAbosAktiv\':false%7D&tf=%7B\'abotypId\':\'\',\'aktiv\':true%7D">' + key + '</a></b>';
          } else if (/aboid|abo_id|abo-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/abos?q=id%3D' + uniqueItems + '&f=%7B\'zusatzAbosAktiv\':true%7D&tf=%7B\'abotypId\':\'\',\'aktiv\':true%7D">' + key + '</a></b>';
          } else if (/personid|person_id|person-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/personen?q=id%3D' + uniqueItems + '&tf=%7B%22kundentypen%22:%22%22,%22personentypen%22:%22%22%7D">' + key + '</a></b>';
          } else if (/rechnungpositionid|rechnungposition_id|rechnungposition-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/rechnungspositionen?q=id%3D' + uniqueItems + '&tf=%7B%22status%22:%22%22%7D">' + key + '</a></b>';
          } else if (/einkaufsrechnungid|einkaufsrechnung_id|einkaufsrechnung-id|sammelbestellungid|sammelbestellung-id|sammelbestellung_id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/einkaufsrechnungen?q=id%3D' + uniqueItems + '&tf=%7B%7D">' + key + '</a></b>';
          } else if (/rechnung_id|rechnungId|rechnung-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/rechnungen?q=id%3D' + uniqueItems + '&tf=%7B%22status%22:%22%22%7D">' + key + '</a></b>';
          } else {
            return '<b>' + key + '</b>';
          }
        }
        return '<b>' + key + '</b>';
      };

      $scope.executeReport = function() {
        $scope.result = {};
        ReportsModel.executeReport({
          id: $scope.report.id,
          query: $scope.report.query
        }, function(data) {
          if (data && data[0]) {
            $scope.cols = [];
            for (var key in data[0]) {
              if (key.indexOf('$') !== 0 && key !== 'toJSON') {
                $scope.cols.push({
                  field: key,
                  getValue: $scope.renderedInput
                });
              }<commit_msg>dropped the additional params<commit_after>'use strict';

/**
 */
angular.module('openolitor-admin')
  .controller('ReportsDetailController', ['$scope', '$rootScope', '$filter', '$routeParams',
    '$location', '$uibModal', 'gettext', 'ReportsModel', '$log', 'NgTableParams', 'lodash',
    function($scope, $rootScope, $filter, $routeParams, $location, $uibModal, gettext, ReportsModel, $log, NgTableParams, lodash) {
      $rootScope.viewId = 'D-Rept';

      $scope.isModifying = false;

      $scope.result = {
        entries: []
      }
      $scope.cols = [];

      var defaults = {
        model: {
          id: undefined
        }
      };

      $scope.search = {
        query: ''
      };

      if (!$routeParams.id || $routeParams.id === 'new') {
        $scope.isModifying = true;
        $scope.report = new ReportsModel(defaults.model);
      } else {
        ReportsModel.get({
          id: $routeParams.id
        }, function(result) {
          result.query = sqlFormatter.format(result.query);
          $scope.report = result;
        });
      }

      $scope.isExisting = function() {
        return angular.isDefined($scope.report) && angular.isDefined($scope.report.id);
      };

      $scope.renderedInput = function($scope, row) {
        if (row[this.field] !== null) {
          if (/kundeid|kunde_id|kunde-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/kunden/' + row[this.field] + '">' + row[this.field] + '</a>';
          } else if (/zusatz-abo-id|zusatz_abo_id|zusatzaboid|zusatzabo_id|zusatzabo-id/.test(this.field.toLowerCase())) {
            return row[this.field];
          } else if (/abotypid|abotyp_id|abotyp-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/abotypen/' + row[this.field] + '">' + row[this.field] + '</a>';
          } else if (/aboid|abo_id|abo-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/abos/q=id%3D' + row[this.field] + '">' + row[this.field] + '</a>';
          } else if (/tourid|tour_id|tour-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/touren/' + row[this.field] + '">' + row[this.field] + '</a>';
          } else if (/depotid|depot_id|depot-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/depots/' + row[this.field] + '">' + row[this.field] + '</a>';
          } else if (/produzentid|produzent_id|produzent-id/.test(this.field.toLowerCase())) {
            return '<a href="' + '#/produzenten/' + row[this.field] + '">' + row[this.field] + '</a>';
          } else {
            return row[this.field];
          }
        }
        return row[this.field];
      };

      $scope.renderedTitles = function(key) {
        if (key !== null) {
          if (/kundeid|kunde_id|kunde-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/kunden?q=id%3D' + uniqueItems + '&tf=%7B%22typen%22:%22%22%7D">' + key + '</a></b>';
          } else if (/zusatz-abo-id|zusatz_abo_id|zusatzaboid|zusatzabo_id|zusatzabo-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/zusatzabos?q=id%3D' + uniqueItems + '">' + key + '</a></b>';
          } else if (/aboid|abo_id|abo-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/abos?q=id%3D' + uniqueItems + '">' + key + '</a></b>';
          } else if (/personid|person_id|person-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/personen?q=id%3D' + uniqueItems + '">' + key + '</a></b>';
          } else if (/rechnungpositionid|rechnungposition_id|rechnungposition-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/rechnungspositionen?q=id%3D' + uniqueItems + '">' + key + '</a></b>';
          } else if (/einkaufsrechnungid|einkaufsrechnung_id|einkaufsrechnung-id|sammelbestellungid|sammelbestellung-id|sammelbestellung_id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/einkaufsrechnungen?q=id%3D' + uniqueItems + '">' + key + '</a></b>';
          } else if (/rechnung_id|rechnungId|rechnung-id/.test(key.toLowerCase())) {
            var items = lodash.map($scope.result.entries, key);
            var uniqueItems = lodash.reject(lodash.uniq(items), _.isEmpty);
            return '<b><a href="#/rechnungen?q=id%3D' + uniqueItems + '">' + key + '</a></b>';
          } else {
            return '<b>' + key + '</b>';
          }
        }
        return '<b>' + key + '</b>';
      };

      $scope.executeReport = function() {
        $scope.result = {};
        ReportsModel.executeReport({
          id: $scope.report.id,
          query: $scope.report.query
        }, function(data) {
          if (data && data[0]) {
            $scope.cols = [];
            for (var key in data[0]) {
              if (key.indexOf('$') !== 0 && key !== 'toJSON') {
                $scope.cols.push({
                  field: key,
                  getValue: $scope.renderedInput
                });
              }
{'fraction_non_alphanumeric': 0.19811479548897493, 'fraction_numerical': 0.007911126073051675, 'mean_word_length': 2.418584579976985, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 0, '>': 91, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2763968', 'n_tokens_mistral': 4120, 'n_tokens_neox': 4007, 'n_words': 608}