<commit_before>/**
 * CONTROLLER: InstancesController
 */

(function () {
    'use strict';


    angular
        .module('myApp')
        .controller('InstancesController', InstancesController);

    function InstancesController(InstancesCacheService, ScalingCacheService, ToastService) {
        var vm = this;

        // Instances
        vm.instances = [];

        // Scaling
        vm.updateScaling = updateScaling;

        vm.scaling = {
            min: 0,
            required: 0,
            max: 0,
        };

        // Load datas
        load();


        ////////////

        function load() {
            InstancesCacheService
                .getAllInstances()
                .then(function (instances) {
                    vm.instances = instances;
                });

            ScalingCacheService
                .getScaling()
                .then(function (scaling) {
                    vm.scaling = scaling;
                });
        }

        function updateScaling() {
            vm.scaling.min = Math.max(0, vm.scaling.min || 0);
            vm.scaling.required = Math.max(0, vm.scaling.required || 0);
            vm.scaling.max = Math.max(0, vm.scaling.max || 0);

            if (vm.scaling.min > vm.scaling.required) {
                vm.scaling.required = vm.scaling.min;
            }

            if (vm.scaling.max < vm.scaling.required) {
                vm.scaling.max = vm.scaling.required;
            }

            ScalingCacheService
                .updateScaling(vm.scaling)
                .catch(function (err) {
                    ToastService.error('Cannot update scaling: ' + err);
                });
        }
    }

})();<commit_msg>feat(service): add error popup when services cannot retrieve datas<commit_after>/**
 * CONTROLLER: InstancesController
 */

(function () {
    'use strict';


    angular
        .module('myApp')
        .controller('InstancesController', InstancesController);

    function InstancesController($log, InstancesCacheService, ScalingCacheService, ToastService) {
        var vm = this;

        // Instances
        vm.instances = [];

        // Scaling
        vm.updateScaling = updateScaling;

        vm.scaling = {
            min: 0,
            required: 0,
            max: 0,
        };

        // Load datas
        load();


        ////////////

        function load() {
            InstancesCacheService
                .getAllInstances()
                .then(function (instances) {
                    vm.instances = instances;
                })
                .catch(function(err) {
                    $log.error(err);
                    ToastService.error('Cannot load instances');
                });

            ScalingCacheService
                .getScaling()
                .then(function (scaling) {
                    vm.scaling = scaling;
                })
                .catch(function(err) {
                    $log.error(err);
                    ToastService.error('Cannot load scaling');
                });
        }

        function updateScaling() {
            vm.scaling.min = Math.max(0, vm.scaling.min || 0);
            vm.scaling.required = Math.max(0, vm.scaling.required || 0);
            vm.scaling.max = Math.max(0, vm.scaling.max || 0);

            if (vm.scaling.min > vm.scaling.required) {
                vm.scaling.required = vm.scaling.min;
            }

            if (vm.scaling.max < vm.scaling.required) {
                vm.scaling.max = vm.scaling.required;
            }

            ScalingCacheService
                .updateScaling(vm.scaling)
                .catch(function (err) {
                    $log.error(err);
                    ToastService.error('Cannot update scaling: ' + err);
                });
        }
    }

})();
{'fraction_non_alphanumeric': 0.11909758656873033, 'fraction_numerical': 0.00472193074501574, 'mean_word_length': 1.2642517814726841, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7312365', 'n_tokens_mistral': 1080, 'n_tokens_neox': 956, 'n_words': 177}