<commit_before>define( [ "ember" ],function( Ember ) {

	return Ember.Mixin.create({
		offset: 0,
		limit: 12,
		maxAutoFetches: 3,


		beforeModel: function() {
			this._super.apply( this, arguments );

			this.set( "offset", 0 );
		},

		setupController: function( controller ) {
			this._super.apply( this, arguments );

			controller.set( "isFetching", false );
			controller.set( "hasFetchedAll", false );
		},

		fetchContent: function() {
			return this.model();
		},

		actions: {
			"willFetchContent": function( force ) {
				var controller = this.get( "controller" );
				if ( !controller.get( "isFetching" ) && !controller.get( "hasFetchedAll" ) ) {
					// don't fetch more than 3 times automatically
					var numFetches = this.get( "offset" ) / this.get( "limit" );
					if ( !force && this.get( "maxAutoFetches" ) <= numFetches ) {
						return;
					}

					controller.toggleProperty( "isFetching" );
					this.incrementProperty( "offset", this.get( "limit" ) );

					// fetch content and append to ArrayController
					this.fetchContent().then(function( content ) {
						if ( !content || !content.length ) {
							controller.set( "hasFetchedAll", true );
						} else {
							controller.pushObjects( content );
						}
						controller.toggleProperty( "isFetching" );
					}.bind( this ) );
				}
			}
		}
	});

});
<commit_msg>Fixed infinitescroll button showing up when there's nothing more to fetch<commit_after>define( [ "ember" ],function( Ember ) {

	return Ember.Mixin.create({
		offset: 0,
		limit: 12,
		maxAutoFetches: 3,


		beforeModel: function() {
			this._super.apply( this, arguments );

			this.set( "offset", 0 );
		},

		setupController: function( controller, model ) {
			var	num	= Ember.get( model, "length" ),
				max	= Ember.get( this, "limit" );

			this._super.apply( this, arguments );

			controller.set( "isFetching", false );
			controller.set( "hasFetchedAll", num < max );
		},

		fetchContent: function() {
			return this.model();
		},

		actions: {
			"willFetchContent": function( force ) {
				var controller = this.get( "controller" );
				if ( !controller.get( "isFetching" ) && !controller.get( "hasFetchedAll" ) ) {
					// don't fetch more than 3 times automatically
					var numFetches = this.get( "offset" ) / this.get( "limit" );
					if ( !force && this.get( "maxAutoFetches" ) <= numFetches ) {
						return;
					}

					controller.toggleProperty( "isFetching" );
					this.incrementProperty( "offset", this.get( "limit" ) );

					// fetch content and append to ArrayController
					this.fetchContent().then(function( content ) {
						if ( !content || !content.length ) {
							controller.set( "hasFetchedAll", true );
						} else {
							controller.pushObjects( content );
						}
						controller.toggleProperty( "isFetching" );
					}.bind( this ) );
				}
			}
		}
	});

});

{'fraction_non_alphanumeric': 0.15468256752016837, 'fraction_numerical': 0.004209049456331112, 'mean_word_length': 2.9015047879616964, 'pattern_counts': {'":': 2, '<': 6, '<?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': '921950', 'n_tokens_mistral': 1168, 'n_tokens_neox': 917, 'n_words': 211}