<commit_before>import Ember from 'ember';

export default Ember.Controller.extend({
    model: null,
    store: Ember.inject.service(),
    isDirty: function() {
        // TODO: check the session model to see if it contains unsaved data
        var session = this.get('session');
        return session.get('hasDirtyAttributes');
    },
    actions: {
        saveSession(payload) {
            // Save a provided javascript object to a session object
            var session = this.get('session');
            session.setProperties(payload);
            session.save();
            this.set('session', session);
        }
    },
    _session: null,
    session: Ember.computed('model', {
        get: function() {
            var session = this.get('store').createRecord(this.get('model.sessionCollectionId'), {
                experimentId: this.get('experiment.id'),
                profileId: 'tester0.prof1', // TODO fetch from service
                profileVersion: '',
                softwareVersion: ''
            });
            this.get('model').getCurrentVersion().then(function(versionId) {
                session.set('experimentVersion', versionId);
            });
            this.set('session', session);
            return session;
        },
        set: function(session) {
            this.set('_session', session);
            return session;
        }
    })
});
<commit_msg>Fix preview controller's session setter<commit_after>import Ember from 'ember';

export default Ember.Controller.extend({
    model: null,
    store: Ember.inject.service(),
    isDirty: function() {
        // TODO: check the session model to see if it contains unsaved data
        var session = this.get('session');
        return session.get('hasDirtyAttributes');
    },
    actions: {
        saveSession(payload) {
            // Save a provided javascript object to a session object
            var session = this.get('session');
            session.setProperties(payload);
            session.save();
            this.set('session', session);
        }
    },
    _session: null,
    session: Ember.computed('model', {
        get: function() {
            var session = this.get('store').createRecord(this.get('model.sessionCollectionId'), {
                experimentId: this.get('experiment.id'),
                profileId: 'tester0.prof1', // TODO fetch from service
                profileVersion: '',
                softwareVersion: ''
            });
            this.get('model').getCurrentVersion().then(function(versionId) {
                session.set('experimentVersion', versionId);
            });
            this.set('session', session);
            return session;
        },
        set: function(_, session) {
            this.set('_session', session);
            return session;
        }
    })
});

{'fraction_non_alphanumeric': 0.12566184256971408, 'fraction_numerical': 0.0014119308153900459, 'mean_word_length': 1.9337474120082816, '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': '4707954', 'n_tokens_mistral': 719, 'n_tokens_neox': 707, 'n_words': 165}