<commit_before>//= require ../store

(function () {

"use strict";

var JobOutput = FlynnDashboard.Stores.JobOutput = FlynnDashboard.Store.createClass({
	displayName: "Stores.JobOutput",

	getState: function () {
		return this.state;
	},

	willInitialize: function () {
		this.props = {
			appId: this.id.appId,
			jobId: this.id.jobId
		};
	},

	didInitialize: function () {},

	didBecomeActive: function () {
		this.__openEventStream();
	},

	didBecomeInactive: function () {
		return this.constructor.__super__.didBecomeInactive.apply(this, arguments).then(function () {
			if (this.__eventSource) {
				this.__eventSource.close();
				this.setState({
					open: false
				});
			}
		}.bind(this));
	},

	getInitialState: function () {
		return {
			open: false,
			eof: false,
			output: [],
			streamError: null
		};
	},

	handleEvent: function () {
	},

	__openEventStream: function (retryCount) {
		if ( !window.hasOwnProperty('EventSource') ) {
			return;
		}

		this.setState(Marbles.Utils.extend(this.getInitialState(), {open: true}));

		var url = FlynnDashboard.config.endpoints.cluster_controller + "/apps/"+ this.props.appId +"/jobs/"+ this.props.jobId +"/log?tail=true";
		var eventSource;
		var open = false;
		eventSource = new window.EventSource(url, {withCredentials: true});
		eventSource.addEventListener("error", function () {
			eventSource.close();
			if ( !open && (!retryCount || retryCount < 3) ) {
				setTimeout(function () {
					this.__openEventStream((retryCount || 0) + 1);
				}.bind(this), 300);
			} else {
				this.setState({
					open: false,
					eof: false,
					streamError: "Failed to connect to log"
				});
			}
		}.bind(this), false);
		eventSource.addEventListener("open", function () {
			open = true;
		});
		eventSource.addEventListener("message", function (e) {
			this.setState({
				output: this.state.output.concat(JSON.parse(e.data))
			});
		}.bind(this), false);
		eventSource.addEventListener("eof", function () {
			this.setState({
				open: false,
				eof: true
			});
			eventSource.close();
		}.bind(this), false);

		this.__eventSource = eventSource;
	}

}, Marbles.State);

JobOutput.registerWithDispatcher(FlynnDashboard.Dispatcher);

})();<commit_msg>Fix launch app view when app successfuly launches<commit_after>//= require ../store

(function () {

"use strict";

var JobOutput = FlynnDashboard.Stores.JobOutput = FlynnDashboard.Store.createClass({
	displayName: "Stores.JobOutput",

	getState: function () {
		return this.state;
	},

	willInitialize: function () {
		this.props = {
			appId: this.id.appId,
			jobId: this.id.jobId
		};
	},

	didInitialize: function () {},

	didBecomeActive: function () {
		this.__openEventStream();
	},

	didBecomeInactive: function () {
		return this.constructor.__super__.didBecomeInactive.apply(this, arguments).then(function () {
			if (this.__eventSource) {
				this.__eventSource.close();
				this.setState({
					open: false
				});
			}
		}.bind(this));
	},

	getInitialState: function () {
		return {
			open: false,
			eof: false,
			output: [],
			streamError: null
		};
	},

	handleEvent: function () {
	},

	__openEventStream: function (retryCount) {
		if ( !window.hasOwnProperty('EventSource') ) {
			return;
		}

		this.setState(Marbles.Utils.extend(this.getInitialState(), {open: true}));

		var url = FlynnDashboard.config.endpoints.cluster_controller + "/apps/"+ this.props.appId +"/jobs/"+ this.props.jobId +"/log?tail=true";
		var eventSource;
		var open = false;
		eventSource = new window.EventSource(url, {withCredentials: true});
		eventSource.addEventListener("error", function () {
			eventSource.close();
			if ( !open && (!retryCount || retryCount < 3) ) {
				setTimeout(function () {
					this.__openEventStream((retryCount || 0) + 1);
				}.bind(this), 300);
			} else {
				this.setState({
					open: false,
					eof: false,
					streamError: "Failed to connect to log"
				});
			}
		}.bind(this), false);
		eventSource.addEventListener("open", function () {
			open = true;
		});
		eventSource.addEventListener("message", function (e) {
			this.setState({
				output: this.state.output.concat(JSON.parse(e.data))
			});
		}.bind(this), false);
		eventSource.addEventListener("eof", function () {
			this.setState({
				open: false,
				eof: true
			});
			eventSource.close();
		}.bind(this), false);
		eventSource.addEventListener("exit", function () {
			this.setState({
				open: false,
				eof: true
			});
			eventSource.close();
		}.bind(this), false);

		this.__eventSource = eventSource;
	}

}, Marbles.State);

JobOutput.registerWithDispatcher(FlynnDashboard.Dispatcher);

})();
{'fraction_non_alphanumeric': 0.16299178555987895, 'fraction_numerical': 0.0025940337224383916, 'mean_word_length': 3.6362725450901805, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5919841', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1525, 'n_words': 283}