<commit_before>'use strict';
/*global _*/
/* global addValidOperatorsToFields*/

//  Card Controllers
var CardControllers = angular.module('corvus.card.controllers', ['corvusadmin.query.services']);

CardControllers.controller('CardList', ['$scope', '$location', 'Card', function($scope, $location, Card) {

    // $scope.cards: the list of cards being displayed

    $scope.deleteCard = function(cardId) {
        Card.delete({
            'cardId': cardId
        }, function(result) {
            $scope.cards = _.filter($scope.cards, function(card) {
                return card.id != cardId;
            });
            $scope.searchFilter = undefined;
        });
    };

    $scope.unfavorite = function(unfavIdx) {
        var cardToUnfav = $scope.cards[unfavIdx];
        Card.unfavorite({
            'cardId': cardToUnfav.id
        }, function(result) {
            $scope.cards.splice(unfavIdx, 1);
        });
    };

    $scope.filter = function(filterMode) {
        $scope.filterMode = filterMode;

        $scope.$watch('currentOrg', function(org) {
            if (!org) return;

            Card.list({
                'orgId': org.id,
                'filterMode': filterMode
            }, function(cards) {
                $scope.cards = cards;
            }, function(error) {
                console.log('error getting cards list', error);
            });
        });
    };

    $scope.inlineSave = function(card, idx) {
        Card.update(card, function(result) {
            if (result && !result.error) {
                $scope.cards[idx] = result;
            } else {
                return "error";
            }
        });
    };

    // determine the appropriate filter to start with
    if ($scope.hash && $scope.hash === 'fav') {
        $scope.filter('fav');
    } else {
        $scope.filter('all');
    }

}]);

CardControllers.controller('CardDetail', [
    '$scope', '$routeParams', '$location', '$window', '$timeout', 'Card', 'Query', 'Metabase', 'CorvusFormGenerator', 'VisualizationSettings',
    function($scope, $routeParams, $location, $window, $timeout, Card, Query, Metabase, CorvusFormGenerator, VisualizationSettings) {
        /* number of milliseconds to wait before
         * notifying the card that the visualization
         * settings have changed (useful so the card
         * doesn't refresh while typing)
         */
        var SETTINGS_CHANGE_REFRESH_DELAY_IN_MS = 500;

        /* maximum number of rows a dataset can have
         * to be usable for to render an axis chart
         * (i.e. line, bar, timeseries)
         */
        var AXIS_CHART_MAX_ROWS = 1000;

        /* maximum number of rows a dataset can have
         * to be usable to render a pie chart
         */<commit_msg>losen things<commit_after>'use strict';
/*global _*/
/* global addValidOperatorsToFields*/

//  Card Controllers
var CardControllers = angular.module('corvus.card.controllers', ['corvusadmin.query.services']);

CardControllers.controller('CardList', ['$scope', '$location', 'Card', function($scope, $location, Card) {

    // $scope.cards: the list of cards being displayed

    $scope.deleteCard = function(cardId) {
        Card.delete({
            'cardId': cardId
        }, function(result) {
            $scope.cards = _.filter($scope.cards, function(card) {
                return card.id != cardId;
            });
            $scope.searchFilter = undefined;
        });
    };

    $scope.unfavorite = function(unfavIdx) {
        var cardToUnfav = $scope.cards[unfavIdx];
        Card.unfavorite({
            'cardId': cardToUnfav.id
        }, function(result) {
            $scope.cards.splice(unfavIdx, 1);
        });
    };

    $scope.filter = function(filterMode) {
        $scope.filterMode = filterMode;

        $scope.$watch('currentOrg', function(org) {
            if (!org) return;

            Card.list({
                'orgId': org.id,
                'filterMode': filterMode
            }, function(cards) {
                $scope.cards = cards;
            }, function(error) {
                console.log('error getting cards list', error);
            });
        });
    };

    $scope.inlineSave = function(card, idx) {
        Card.update(card, function(result) {
            if (result && !result.error) {
                $scope.cards[idx] = result;
            } else {
                return "error";
            }
        });
    };

    // determine the appropriate filter to start with
    if ($scope.hash && $scope.hash === 'fav') {
        $scope.filter('fav');
    } else {
        $scope.filter('all');
    }

}]);

CardControllers.controller('CardDetail', [
    '$scope', '$routeParams', '$location', '$window', '$timeout', 'Card', 'Query', 'Metabase', 'CorvusFormGenerator', 'VisualizationSettings',
    function($scope, $routeParams, $location, $window, $timeout, Card, Query, Metabase, CorvusFormGenerator, VisualizationSettings) {
        /* number of milliseconds to wait before
         * notifying the card that the visualization
         * settings have changed (useful so the card
         * doesn't refresh while typing)
         */
        var SETTINGS_CHANGE_REFRESH_DELAY_IN_MS = 500;

        /* maximum number of rows a dataset can have
         * to be usable for to render an axis chart
         * (i.e. line, bar, timeseries)
         */
        var AXIS_CHART_MAX_ROWS = 5000;

        /* maximum number of rows a dataset can have
         * to be usable to render a pie chart
         */
{'fraction_non_alphanumeric': 0.13345421577515865, 'fraction_numerical': 0.002901178603807797, 'mean_word_length': 2.0644444444444443, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5321303', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1526, 'n_words': 375}