<commit_before>define([
	'knockout',
	'durandal/system',
	'plugins/http',
	'jquery'
], function(
	ko,
	system,
	http,
	$
) {

	'use strict';

	function LastExecution() {
		this.nightlies = ko.observableArray();
		this.scenarios = ko.observableArray();
		this.tags = ko.observableArray();
		this.selectedTags = ko.observableArray();
		this._isLoading = ko.observable(false);
		this._filterActivated = ko.observable(false);
		this.filterFilter = ko.observable('');

		this.selectedTags.subscribe(this._filterByTags.bind(this));
		this.filterFilter.subscribe(this._filterShownTags.bind(this));
	}

	LastExecution.prototype.activate = function() {
		this._filterActivated(false);
		var dfd = system.defer();
		this._call().then(
			this._onData.bind(this, dfd),
			this._onError.bind(this, dfd)
		);
		return dfd.promise();
	};

	LastExecution.prototype.attached = function(view) {
		this._viewElm = view;
	};

	LastExecution.prototype._call = function() {
		this._isLoading(true);
		return http.get('/lastExecution');
	};

	LastExecution.prototype._onData = function(dfd, data) {
		this._filterActivated(false);
		this.scenarios.removeAll();
		this.tags.removeAll();
		// this.tags.push('ALL');
		// this.selectedTags(['ALL']);

		var forEachTag = (function(tag){
			if(this.tags.indexOf(tag) === -1) {
				this.tags.push(tag);
			}
		}).bind(this);

		var forEachScenario = (function(nightly, scenario) {
			if(!!scenario.results && !!scenario.results[0] && scenario.results[0].buildId === nightly.build) {
				scenario._parent = nightly;
				this.scenarios.push(scenario);
				if(scenario.hasOwnProperty('tags')) {
					scenario.tags.forEach(forEachTag);
				}
			}
		}).bind(this);

		data.forEach((function(nightly) {
			nightly.scenarios.forEach(forEachScenario.bind(this, nightly));
		}).bind(this));

		this.tags.sort();

		this._isLoading(false);<commit_msg>FIX: showing last executed scenarios in last Executions<commit_after>define([
	'knockout',
	'durandal/system',
	'plugins/http',
	'jquery'
], function(
	ko,
	system,
	http,
	$
) {

	'use strict';

	function LastExecution() {
		this.nightlies = ko.observableArray();
		this.scenarios = ko.observableArray();
		this.tags = ko.observableArray();
		this.selectedTags = ko.observableArray();
		this._isLoading = ko.observable(false);
		this._filterActivated = ko.observable(false);
		this.filterFilter = ko.observable('');

		this.selectedTags.subscribe(this._filterByTags.bind(this));
		this.filterFilter.subscribe(this._filterShownTags.bind(this));
	}

	LastExecution.prototype.activate = function() {
		this._filterActivated(false);
		var dfd = system.defer();
		this._call().then(
			this._onData.bind(this, dfd),
			this._onError.bind(this, dfd)
		);
		return dfd.promise();
	};

	LastExecution.prototype.attached = function(view) {
		this._viewElm = view;
	};

	LastExecution.prototype._call = function() {
		this._isLoading(true);
		return http.get('/lastExecution');
	};

	LastExecution.prototype._onData = function(dfd, data) {
		this._filterActivated(false);
		this.scenarios.removeAll();
		this.tags.removeAll();
		// this.tags.push('ALL');
		// this.selectedTags(['ALL']);

		var forEachTag = (function(tag){
			if(this.tags.indexOf(tag) === -1) {
				this.tags.push(tag);
			}
		}).bind(this);

		var forEachScenario = (function(nightly, scenario) {
			var lE = !!scenario.results && scenario.results.length ? scenario.results[scenario.results.length -1] : null;
			if(!!lE && lE.buildId === nightly.build) {
				scenario._parent = nightly;
				this.scenarios.push(scenario);
				if(scenario.hasOwnProperty('tags')) {
					scenario.tags.forEach(forEachTag);
				}
			}
		}).bind(this);

		data.forEach((function(nightly) {
			nightly.scenarios.forEach(forEachScenario.bind(this, nightly));
		}).bind(this));

		this.tags.sort();

		this._isLoading(false);
{'fraction_non_alphanumeric': 0.17019607843137255, 'fraction_numerical': 0.00130718954248366, 'mean_word_length': 4.313888888888889, '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': '1999154', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1311, 'n_words': 184}