<commit_before>(function($, _, Backbone) {
    _.extend(Backbone.Model.prototype, {
        idAttribute: 'resource_uri',

        url: function() {
            var url = getValue(this, 'urlRoot') || getValue(this.collection, 'urlRoot') || urlError();
            
            if (this.isNew())
                return url;

            return this.get('resource_uri');
        },
        _getId: function() {
            if (this.has('id'))
                return this.get('id');

            return _.chain(this.get('resource_uri').split('/')).compact().last().value();
        }
    });

    _.extend(Backbone.Collection.prototype, {
        meta: {},

        initialize: function(collections, options) {
            _.bindAll(this, 'fetchNext', 'fetchPrevious');

            this.filters = (options && options.filters) || {
                limit: 20,
                offset: 0
            };
        },
        url: function(models) {
            var url = this.urlRoot;

            if (models) {
                var ids = _.map(models, function(model) {
                    return model._getId();
                });

                url += 'set/' + ids.join(';') + '/';
            }

            return url + this._getQueryString();
        },
        parse: function(response) {
            if (response && response.meta)
                this.meta = response.meta;

            return response && response.objects;
        },
        fetchNext: function(options) {
            options.add = true;

            this.filters.limit = this.meta.limit;
            this.filters.offset = this.meta.offset + this.meta.limit;

            if (this.filters.offset > this.meta.total_count)
                this.filters.offset = this.meta.total_count;
<commit_msg>Added ability to set default limit and fixed issue with merging filters on model init.<commit_after>(function($, _, Backbone) {
    Backbone.Tastypie = {
        defaultLimit: 20
    };

    _.extend(Backbone.Model.prototype, {
        idAttribute: 'resource_uri',

        url: function() {
            var url = getValue(this, 'urlRoot') || getValue(this.collection, 'urlRoot') || urlError();
            
            if (this.isNew())
                return url;

            return this.get('resource_uri');
        },
        _getId: function() {
            if (this.has('id'))
                return this.get('id');

            return _.chain(this.get('resource_uri').split('/')).compact().last().value();
        }
    });

    _.extend(Backbone.Collection.prototype, {
        meta: {},
        filters: {
            limit: Backbone.Tastypie.defaultLimit,
            offset: 0
        },

        initialize: function(collections, options) {
            _.bindAll(this, 'fetchNext', 'fetchPrevious');

            if (options && options.filters)
                _.extend(this.filters, options.filters);
        },
        url: function(models) {
            var url = this.urlRoot;

            if (models) {
                var ids = _.map(models, function(model) {
                    return model._getId();
                });

                url += 'set/' + ids.join(';') + '/';
            }

            return url + this._getQueryString();
        },
        parse: function(response) {
            if (response && response.meta)
                this.meta = response.meta;

            return response && response.objects;
        },
        fetchNext: function(options) {
            options.add = true;

            this.filters.limit = this.meta.limit;
            this.filters.offset = this.meta.offset + this.meta.limit;

            if (this.filters.offset > this.meta.total_count)
                this.filters.offset = this.meta.total_count;

{'fraction_non_alphanumeric': 0.13588850174216027, 'fraction_numerical': 0.0016081479496113642, 'mean_word_length': 1.5509227614490773, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4969761', 'n_tokens_mistral': 1016, 'n_tokens_neox': 968, 'n_words': 192}