<commit_before>(function (Backbone, _, $, undefined) {
"use strict";

Backbone.$ = $;

window.Daybed = window.Daybed || {};

/**
 * Default settings
 */
Daybed.SETTINGS = {
    SERVER: "localhost:8000"
};

//
//  Item : a record
//
Daybed.Item = Backbone.Model.extend({
    url: function () {
        return URI.build({hostname: Daybed.SETTINGS.SERVER,
                          path: '/data/' + this.definition.id});
    },

    /**
     * Fields values
     */
    fieldsValues: function () {
        var columns = this.definition.fieldsNames(),
            fields = _.pick.apply(_, ([this.attributes]).concat(columns));
        return _.values(fields);
    }
});


Daybed.ItemList = Backbone.Collection.extend({
    model: Daybed.Item,

    initialize: function (definition) {
        this.definition = definition;
    },

    url: function () {
        return URI.build({hostname: Daybed.SETTINGS.SERVER,
                          path: '/data/' + this.definition.id});
    },

    parse: function (response) {
        return response.data;
    },

    /**
     * Override instanciation to link with Definition instance.
     */
    _prepareModel: function () {
        var m = Backbone.Collection.prototype._prepareModel.apply(this, arguments);
        m.definition = this.definition;
        return m;
    }
});


//
//  Definition : a model
//
Daybed.Definition = Backbone.Model.extend({
    /**
     * Backbone.forms schema for Definition forms
     */
    schema: {<commit_msg>Wait for definition to be ready before fetching collection<commit_after>(function (Backbone, _, $, undefined) {
"use strict";

Backbone.$ = $;

window.Daybed = window.Daybed || {};

/**
 * Default settings
 */
Daybed.SETTINGS = {
    SERVER: "localhost:8000"
};

//
//  Item : a record
//
Daybed.Item = Backbone.Model.extend({
    url: function () {
        return URI.build({hostname: Daybed.SETTINGS.SERVER,
                          path: '/data/' + this.definition.id});
    },

    /**
     * Fields values
     */
    fieldsValues: function () {
        var columns = this.definition.fieldsNames(),
            fields = _.pick.apply(_, ([this.attributes]).concat(columns));
        return _.values(fields);
    }
});


Daybed.ItemList = Backbone.Collection.extend({
    model: Daybed.Item,

    initialize: function (definition) {
        this.definition = definition;
    },

    url: function () {
        return URI.build({hostname: Daybed.SETTINGS.SERVER,
                          path: '/data/' + this.definition.id});
    },

    parse: function (response) {
        return response.data;
    },

    /**
     * Fetch only once Definition is ready.
     */
    fetch: function () {
        var args = Array.prototype.slice.call(arguments);
        this.definition.whenReady((function () {
            Backbone.Collection.prototype.fetch.apply(this, args);
        }).bind(this));
    },

    /**
     * Override instanciation to link with Definition instance.
     */
    _prepareModel: function () {
        var m = Backbone.Collection.prototype._prepareModel.apply(this, arguments);
        m.definition = this.definition;
        return m;
    }
});


//
//  Definition : a model
//
Daybed.Definition = Backbone.Model.extend({
    /**
     * Backbone.forms schema for Definition forms
     */
    schema: {
{'fraction_non_alphanumeric': 0.14510278113663846, 'fraction_numerical': 0.0024183796856106408, 'mean_word_length': 2.1847930702598655, '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': '186921', 'n_tokens_mistral': 963, 'n_tokens_neox': 945, 'n_words': 199}