<commit_before>'use strict';

/**
 * @ngdoc directive
 * @name grafterizerApp.directive:clojurePipeline
 * @description
 * # clojurePipeline
 */
angular.module('grafterizerApp')
    .directive('clojurePipeline', function (generateClojure) {
    return {
        template: '<div ui-codemirror="editorOptions" ng-model="clojure"></div>',
        restrict: 'E',
        scope: {
            transformation: '=',
        },
        link: {
            pre: function(scope) {
                scope.editorOptions = {
                    lineWrapping : true, 
                    // lineNumbers: true,
                    mode: 'clojure',
                    // readOnly: true
                };
            },
            post: function(scope, element, attrs) {
                var generatedClojure = null;
                scope.$watch('transformation', function(){
                    if (!scope.transformation) {
                        return;
                    }
                    // console.log(scope.transformation)
                    scope.clojure = generatedClojure = generateClojure.fromTransformation(scope.transformation);
                    scope.isOverrided = false;
                }, true);

                var warningMsg = "; WARNING: Experimental feature\n"+
                    "; The changes will be lost if you edit the transformation\n\n";

                scope.$watch('clojure', function(){
                    if (generatedClojure != scope.clojure) {
                        scope.isOverrided = true;
                        if (scope.clojure.indexOf(warningMsg) === -1) {
                            scope.clojure = warningMsg + scope.clojure;
                        }
                        generateClojure.overrideClojure(scope.clojure, generatedClojure);
                        scope.$parent.$parent.$broadcast('preview-request');
                    }
                });

                // TODO workaround random bug
                scope.$watch("$parent.selectedTabIndex", function(){
                    if (scope['$parent'].selectedTabIndex) {
                        window.setTimeout(function(){
                            try {
                                element.children().children()[0].CodeMirror.refresh();
                            }catch(e){}
                        }, 1);
                    }
                });
            }
        }
    };
});
<commit_msg>Previewing every second is good enough<commit_after>'use strict';

/**
 * @ngdoc directive
 * @name grafterizerApp.directive:clojurePipeline
 * @description
 * # clojurePipeline
 */
angular.module('grafterizerApp')
    .directive('clojurePipeline', function (generateClojure) {
    return {
        template: '<div ui-codemirror="editorOptions" ng-model="clojure"></div>',
        restrict: 'E',
        scope: {
            transformation: '=',
        },
        link: {
            pre: function(scope) {
                scope.editorOptions = {
                    lineWrapping : true, 
                    // lineNumbers: true,
                    mode: 'clojure',
                    // readOnly: true
                };
            },
            post: function(scope, element, attrs) {
                var generatedClojure = null;
                scope.$watch('transformation', function(){
                    if (!scope.transformation) {
                        return;
                    }
                    // console.log(scope.transformation)
                    scope.clojure = generatedClojure = generateClojure.fromTransformation(scope.transformation);
                    scope.isOverrided = false;
                }, true);

                var warningMsg = "; WARNING: Experimental feature\n"+
                    "; The changes will be lost if you edit the transformation\n\n";

                var throttledPreviewRequest = _.throttle(function(){
                    scope.$parent.$parent.$broadcast('preview-request');
                }, 1000);

                scope.$watch('clojure', function(){
                    if (generatedClojure != scope.clojure) {
                        scope.isOverrided = true;
                        if (scope.clojure.indexOf(warningMsg) === -1) {
                            scope.clojure = warningMsg + scope.clojure;
                        }
                        generateClojure.overrideClojure(scope.clojure, generatedClojure);
                        throttledPreviewRequest();
                    }
                });

                // TODO workaround random bug
                scope.$watch("$parent.selectedTabIndex", function(){
                    if (scope['$parent'].selectedTabIndex) {
                        window.setTimeout(function(){
                            try {
                                element.children().children()[0].CodeMirror.refresh();
                            }catch(e){}
                        }, 1);
                    }
                });
            }
        }
    };
});

{'fraction_non_alphanumeric': 0.1093562574970012, 'fraction_numerical': 0.001999200319872051, 'mean_word_length': 1.2205947625388371, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4811220', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1150, 'n_words': 202}