<commit_before>define('app/controllers/machines', [
    'app/models/machine',
    'ember',
    'jquery'
    ],
    /**
     * Machines controller
     *
     * @returns Class
     */
    function(Machine) {
        return Ember.ArrayController.extend({
            backend: null,

            content: null,

            init: function() {
                this._super();
                this.set('content', []),
                this.refresh();
            },

            refresh: function(){

                if(!this.backend.enabled){
                    this.backend.set('state', 'offline');
                    this.clear();
                    return;
                }

                var that = this;

                
                this.backend.set('state', 'waiting');

                $.getJSON('/backends/' + this.backend.id + '/machines', function(data) {

                    data.forEach(function(item){
                        var found = false;

                        log("item id: " + item.id);

                        that.content.forEach(function(machine){
                            if (machine.id == item.id || (machine.id == -1 && machine.name == item.name)) {
                                found = true;
                                // machine.set(item); //FIXME this does not change anything;
                                if (machine.id == -1) {
                                    machine.set('id', item.id);
                                }
                                machine.set('state', item.state);
                                machine.set('can_stop', item.can_stop);
                                machine.set('can_start', item.can_start);
                                machine.set('can_destroy', item.can_destroy);
                                machine.set('can_reboot', item.can_reboot);
                                machine.set('can_tag', item.can_tag);
                                //FIXME check for changes
                                machine.tags.set('content', item.tags)
                                machine.set('public_ips', item.public_ips);
                                machine.set('extra', item.extra);
                                return false;
                            }
                        });

                        if (!found && !that.backend.create_pending) {
                            item.backend = that.backend;
                            var machine = Machine.create(item);
                            machine.tags.set('content', item.tags)
                            that.pushObject(machine);
                        }

                    });<commit_msg>add a check if monitoring has fetched the data but list_machines has not received results. Thus re check that a machine has monitoring<commit_after>define('app/controllers/machines', [
    'app/models/machine',
    'ember',
    'jquery'
    ],
    /**
     * Machines controller
     *
     * @returns Class
     */
    function(Machine) {
        return Ember.ArrayController.extend({
            backend: null,

            content: null,

            init: function() {
                this._super();
                this.set('content', []),
                this.refresh();
            },

            refresh: function(){

                if(!this.backend.enabled){
                    this.backend.set('state', 'offline');
                    this.clear();
                    return;
                }

                var that = this;

                
                this.backend.set('state', 'waiting');

                $.getJSON('/backends/' + this.backend.id + '/machines', function(data) {

                    data.forEach(function(item){
                        var found = false;

                        log("item id: " + item.id);

                        that.content.forEach(function(machine){
                            if (machine.id == item.id || (machine.id == -1 && machine.name == item.name)) {
                                found = true;
                                // machine.set(item); //FIXME this does not change anything;
                                if (machine.id == -1) {
                                    machine.set('id', item.id);
                                }
                                machine.set('state', item.state);
                                machine.set('can_stop', item.can_stop);
                                machine.set('can_start', item.can_start);
                                machine.set('can_destroy', item.can_destroy);
                                machine.set('can_reboot', item.can_reboot);
                                machine.set('can_tag', item.can_tag);
                                //FIXME check for changes
                                machine.tags.set('content', item.tags)
                                machine.set('public_ips', item.public_ips);
                                machine.set('extra', item.extra);
                                if (typeof Mist.monitored_machines === 'undefined') { 
                                    //check monitoring failed, re-run. This shall be moved though, since here it gets executed just 2 times
                                    Mist.backendsController.checkMonitoring();
                                }
                                Mist.monitored_machines.forEach(function(machine_tuple){
                                    backend_id = machine_tuple[0];
                                    machine_id = machine_tuple[1];
                                    if (that.backend.id == backend_id && machine.id == machine_id && machine.hasMonitoring == false) {
                                        machine.set('hasMonitoring', true);
                                        return false;
                                    }        
                                 });

                                return false;
                            }
                        });

                        if (!found && !that.backend.create_pending) {
                            item.backend = that.backend;
                            var machine = Machine.create(item);
                            machine.tags.set('content', item.tags)
                            that.pushObject(machine);
                        }

                    });
{'fraction_non_alphanumeric': 0.10532098571652802, 'fraction_numerical': 0.001098728614032334, 'mean_word_length': 0.9089275014979029, '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': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '819746', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1351, 'n_words': 260}