<commit_before>var app = app || {};

app.views = app.views || {};

app.views.PaymentHistory = (function() {

	'use strict';

	return app.views.utility.List.extend({

		className: 'payment-history',
		template: '#template-payment-history',
		itemContainer: '.payment-history-items',
		events: {
			'click .payment-history-item': 'showPaymentDetails',
			'scroll': 'onScroll',
		},

		ItemView: function() {
			return app.views.PaymentHistoryListItem;
		},

		offset: 0,
		total: 0,

		initialize: function() {

			_.bindAll(this, 'fetchPayments', 'onScroll');

			this.collection = app.paymentRequests;
		},

		fetchPayments: function() {

			var $el = this.$el;
			$el.addClass('loading');
			window.requestAnimationFrame(_.bind(function() {
				this.collection.fetch({
					limit: app.config.paymentHistory.list.limit,
					offset: this.offset,
					error: function() {
						$el.removeClass('loading');
						app.mainView.showMessage(app.i18n.t('payment-history.failed-to-get-payment-data'));
					},
					success: _.bind(function() {
						$el.removeClass('loading');
						this.$el.toggleClass('empty', this.collection.length === 0);
					}, this),
				});
			}, this));
		},

		onRender: function() {

			app.log('paymentHistory.onRender');
			if (!(this.collection.length > 0)) {
				this.fetchPayments();
			} else {
				this.renderItems();
			}

			this.$items = this.$('.payment-history-items');
			this.$items.on('scroll', this.onScroll);
		},

		onScroll: function(evt) {

			app.log('paymentHistory.onScroll');
			var scrollHeightRemaining = this.getScrollHeightRemaining();
			var threshold = $(window).height() / 3;
			if (scrollHeightRemaining < threshold && this.hasMoreItemsToFetch()) {
				this.offset += app.config.paymentHistory.list.limit;
				this.fetchPayments();
			}
		},

		getScrollHeightRemaining: function() {

			return this.$items.prop('scrollHeight') - (this.$items.scrollTop() + this.$items.outerHeight());
		},

		hasMoreItemsToFetch: function() {

			return this.collection.length < this.collection.total;
		},

		showPaymentDetails: function(evt) {

			if (evt && evt.preventDefault) {
				evt.preventDefault();
			}

			var paymentId = $(evt.currentTarget).attr('data-payment-id');
			app.router.navigate('payment-details/' + paymentId, { trigger: true });
		},

		addItem: function(model) {<commit_msg>fixin not fetching<commit_after>var app = app || {};

app.views = app.views || {};

app.views.PaymentHistory = (function() {

	'use strict';

	return app.views.utility.List.extend({

		className: 'payment-history',
		template: '#template-payment-history',
		itemContainer: '.payment-history-items',
		events: {
			'click .payment-history-item': 'showPaymentDetails',
			'scroll': 'onScroll',
		},

		ItemView: function() {
			return app.views.PaymentHistoryListItem;
		},

		offset: 0,
		total: 0,

		initialize: function() {

			_.bindAll(this, 'fetchPayments', 'onScroll');

			this.collection = app.paymentRequests;
		},

		fetchPayments: function() {

			var $el = this.$el;
			$el.addClass('loading');
			window.requestAnimationFrame(_.bind(function() {
				this.collection.fetch({
					limit: app.config.paymentHistory.list.limit,
					offset: this.offset,
					error: function() {
						$el.removeClass('loading');
						app.mainView.showMessage(app.i18n.t('payment-history.failed-to-get-payment-data'));
					},
					success: _.bind(function() {
						$el.removeClass('loading');
						this.$el.toggleClass('empty', this.collection.length === 0);
					}, this),
				});
			}, this));
		},

		onRender: function() {

			app.log('paymentHistory.onRender');
			if (this.collection.length < app.config.paymentHistory.list.limit) {
				this.fetchPayments();
			} else {
				this.renderItems();
			}
			this.$items = this.$('.payment-history-items');
			this.$items.on('scroll', this.onScroll);
		},

		onScroll: function(evt) {

			app.log('paymentHistory.onScroll');
			var scrollHeightRemaining = this.getScrollHeightRemaining();
			var threshold = $(window).height();
			if (scrollHeightRemaining < threshold && this.hasMoreItemsToFetch()) {
				this.offset += app.config.paymentHistory.list.limit;
				this.fetchPayments();
			}
		},

		getScrollHeightRemaining: function() {

			return this.$items.prop('scrollHeight') - (this.$items.scrollTop() + this.$items.outerHeight());
		},

		hasMoreItemsToFetch: function() {

			return this.collection.length < this.collection.total;
		},

		showPaymentDetails: function(evt) {

			if (evt && evt.preventDefault) {
				evt.preventDefault();
			}

			var paymentId = $(evt.currentTarget).attr('data-payment-id');
			app.router.navigate('payment-details/' + paymentId, { trigger: true });
		},

		addItem: function(model) {
{'fraction_non_alphanumeric': 0.17147707979626486, 'fraction_numerical': 0.0025466893039049238, 'mean_word_length': 3.6070381231671553, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, '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': '4596737', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1480, 'n_words': 237}