<commit_before>/// <reference path="/lib/knockout-3.3.0.js" />

var DeparturesViewModel = (function () {
	
	'use strict';
	
	var DEPARTURE_REFRESH_RATE = 30000;
	
	var DeparturesViewModel = function(updateService) {
		
		var _this = this;
		
		_this.updateService = updateService;
		_this.timer = null;
		
		_this.departures = ko.observableArray();
		_this.error = ko.observable(null);
		_this.hasError = ko.computed(function () {
			return _this.error() === null;
		});
		
	};
	
	function updateDepartures() {
		var _this = this;
		_this.updateService.getDepartures(function(err, newDepartures) {
			if (err) {
				_this.error(err);
				_this.departures([]);
			} else {
				_this.error(null);
				if (newDepartures.length > 6) {
					newDepartures = newDepartures.slice(0, 6);
				}
				_this.departures(newDepartures);
			}
		});
	}
	
	DeparturesViewModel.prototype.startUpdates = function () {
		this.stopUpdates();
		this.timer = window.setInterval(updateDepartures.bind(this), DEPARTURE_REFRESH_RATE);
		updateDepartures.call(this);
	};
	
	DeparturesViewModel.prototype.stopUpdates = function () {
		if (this.timer !== null) {
			clearInterval(this.timer);
			this.timer = null;
		}
	};
		
	return DeparturesViewModel;<commit_msg>Added maximum number of departures.<commit_after>/// <reference path="/lib/knockout-3.3.0.js" />

var DeparturesViewModel = (function () {
	
	'use strict';
	
	var DEPARTURE_REFRESH_RATE = 30000;
	var MAX_DEPARTURES = 4;
	
	var DeparturesViewModel = function(updateService) {
		
		var _this = this;
		
		_this.updateService = updateService;
		_this.timer = null;
		
		_this.departures = ko.observableArray();
		_this.error = ko.observable(null);
		_this.hasError = ko.computed(function () {
			return _this.error() === null;
		});
		
	};
	
	function updateDepartures() {
		var _this = this;
		_this.updateService.getDepartures(function(err, newDepartures) {
			if (err) {
				_this.error(err);
				_this.departures([]);
			} else {
				_this.error(null);
				if (newDepartures.length > MAX_DEPARTURES) {
					newDepartures = newDepartures.slice(0, MAX_DEPARTURES);
				}
				_this.departures(newDepartures);
			}
		});
	}
	
	DeparturesViewModel.prototype.startUpdates = function () {
		this.stopUpdates();
		this.timer = window.setInterval(updateDepartures.bind(this), DEPARTURE_REFRESH_RATE);
		updateDepartures.call(this);
	};
	
	DeparturesViewModel.prototype.stopUpdates = function () {
		if (this.timer !== null) {
			clearInterval(this.timer);
			this.timer = null;
		}
	};
		
	return DeparturesViewModel;
{'fraction_non_alphanumeric': 0.13713163064833006, 'fraction_numerical': 0.008251473477406679, 'mean_word_length': 3.7060998151571165, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5899781', 'n_tokens_mistral': 1061, 'n_tokens_neox': 885, 'n_words': 140}