<commit_before>/// <reference path="HtmlBuilder" />
/// <reference path="printapi/Pullrequest" />

module PrintClient {
	export class PullrequestBuilder {
		static createPRBox(pr: PrintApi.Pullrequest, listView: boolean) {
			var container = HtmlBuilder.createElement("article", "", "id", pr.id);
			var content: Element;
			if (listView)
				content = PullrequestBuilder.buildListViewPRBox(pr);
			else
				content = PullrequestBuilder.buildPRBox(pr);
			container.appendChild(content);
			return container;
		}
		static updatePRBox(pr: PrintApi.Pullrequest, listView: boolean) {
			var success: boolean = false;
			var pr_container = document.getElementById(pr.id);
			if (pr_container) {
				pr_container.innerHTML = "";
				var content: Element;
				if (listView)
					content = PullrequestBuilder.buildListViewPRBox(pr);
				else
					content = PullrequestBuilder.buildPRBox(pr);
				pr_container.appendChild(content);
				success = true;
			}
			return success;
		}
		static buildListViewPRBox(pr: PrintApi.Pullrequest) {
			var main = HtmlBuilder.createElement("main");
			var title = HtmlBuilder.createElement("a", "", "href", "/print/print-client/" + pr.repositoryName + "/pr/" + pr.id);
			title.appendChild(HtmlBuilder.createElement("h2", pr.title + " #" + String(pr.number)));
			main.appendChild(title);
			if (pr.executionResults.length > 0)
				main.appendChild(PullrequestBuilder.createStatusIconForList(pr.executionResults, pr.allJobsComplete));
			main.appendChild(HtmlBuilder.createElement("p", "Created by " + pr.user.username));
			main.appendChild(HtmlBuilder.createElement("p", pr.description));
			return main;
		}
		static buildPRBox(pr: PrintApi.Pullrequest) {
			var main = HtmlBuilder.createElement("main");
			main.appendChild(HtmlBuilder.createElement("h2", pr.title + " #" + String(pr.number)));
			main.appendChild(HtmlBuilder.createElement("p", "Created by " + pr.user.username));
			main.appendChild(HtmlBuilder.createElement("p", pr.description));
			main.appendChild(HtmlBuilder.createElement("p", "Execution status:"));
			pr.executionResults.forEach((result) => {
				var resultContainer = HtmlBuilder.createElement("div");
				var taskHeader = HtmlBuilder.createElement("header", "", "onclick", "printClient.toggleOutput(event, this)");
				taskHeader.appendChild(HtmlBuilder.createElement("p", result.task, "style", "display:inline-block;margin-right:10px;"));
				taskHeader.appendChild(PullrequestBuilder.createStatusIcon(result.result));
				resultContainer.appendChild(taskHeader);
				resultContainer.appendChild(HtmlBuilder.createElement("details", result.output.replace(/\033\[[0-9;]*m/g, ""), "style", "display:none;"));
				main.appendChild(resultContainer);
			});
			return main;
		}
		static createStatusIconForList(executionResults: PrintApi.ExecutionResult[], allJobsComplete: string) {
			var icon = "octicon-server";
			if (allJobsComplete == "true") {
				for (var i = 0; i < executionResults.length; i++) {
					icon = "octicon-check";
					if (executionResults[i].result != "0") {
						icon = "octicon-x";
						i = executionResults.length;
					}
				}
			}
			return HtmlBuilder.createElement("span", "", "class", "octicon " + icon);
		}
		static createStatusIcon(result: string) {
			var icon = "octicon-check";
			if (result != "0")
				icon = "octicon-x";
			return HtmlBuilder.createElement("span", "", "class", "octicon " + icon);
		}
	}
}<commit_msg>Changed how single PR view is updated<commit_after>/// <reference path="HtmlBuilder" />
/// <reference path="printapi/Pullrequest" />

module PrintClient {
	export class PullrequestBuilder {
		static createPRBox(pr: PrintApi.Pullrequest, listView: boolean) {
			var container = HtmlBuilder.createElement("article", "", "id", pr.id);
			var content: Element;
			if (listView)
				content = PullrequestBuilder.buildListViewPRBox(pr);
			else
				content = PullrequestBuilder.buildPRBox(pr);
			container.appendChild(content);
			return container;
		}
		static updatePRBox(pr: PrintApi.Pullrequest, listView: boolean) {
			var success: boolean = false;
			var pr_container = document.getElementById(pr.id);
			if (pr_container) {
				if (listView) {
					pr_container.innerHTML = "";
					var content: Element;
					content = PullrequestBuilder.buildListViewPRBox(pr);
					pr_container.appendChild(content);
				}
				else
					PullrequestBuilder.updateSinglePRBox(pr);
				success = true;
			}
			return success;
		}
		static buildListViewPRBox(pr: PrintApi.Pullrequest) {
			var main = HtmlBuilder.createElement("main");
			var title = HtmlBuilder.createElement("a", "", "href", "/print/print-client/" + pr.repositoryName + "/pr/" + pr.id);
			title.appendChild(HtmlBuilder.createElement("h2", pr.title + " #" + String(pr.number)));
			main.appendChild(title);
			if (pr.executionResults.length > 0)
				main.appendChild(PullrequestBuilder.createStatusIconForList(pr.executionResults, pr.allJobsComplete));
			main.appendChild(HtmlBuilder.createElement("p", "Created by " + pr.user.username));
			main.appendChild(HtmlBuilder.createElement("p", pr.description));
			return main;
		}
		static buildPRBox(pr: PrintApi.Pullrequest) {
			var main = HtmlBuilder.createElement("main");
			main.appendChild(HtmlBuilder.createElement("h2", pr.title + " #" + String(pr.number)));
			main.appendChild(HtmlBuilder.createElement("p", "Created by " + pr.user.username));
			main.appendChild(HtmlBuilder.createElement("p", pr.description));
			main.appendChild(HtmlBuilder.createElement("p", "Execution status:"));
			pr.executionResults.forEach((result) => {
				var resultContainer = HtmlBuilder.createElement("div", "", "id", result.task + pr.id);
				var taskHeader = HtmlBuilder.createElement("header", "", "onclick", "printClient.toggleOutput(event, this)");
				taskHeader.appendChild(HtmlBuilder.createElement("p", result.task, "style", "display:inline-block;margin-right:10px;"));
				taskHeader.appendChild(PullrequestBuilder.createStatusIcon(result.result));
				resultContainer.appendChild(taskHeader);
				resultContainer.appendChild(HtmlBuilder.createElement("details", result.output.replace(/\033\[[0-9;]*m/g, ""), "style", "display:none;"));
				main.appendChild(resultContainer);
			});
			return main;
		}
		static updateSinglePRBox(pr: PrintApi.Pullrequest) {
			var main = document.getElementById(pr.id).firstElementChild;
			pr.executionResults.forEach((result) => {
				var executionResult = document.getElementById(result.task + pr.id);
				if (!executionResult) {
					var resultContainer = HtmlBuilder.createElement("div", "", "id", result.task + pr.id);
					var taskHeader = HtmlBuilder.createElement("header", "", "onclick", "printClient.toggleOutput(event, this)");
					taskHeader.appendChild(HtmlBuilder.createElement("p", result.task, "style", "display:inline-block;margin-right:10px;"));
					taskHeader.appendChild(PullrequestBuilder.createStatusIcon(result.result));
					resultContainer.appendChild(taskHeader);
					resultContainer.appendChild(HtmlBuilder.createElement("details", result.output.replace(/\033\[[0-9;]*m/g, ""), "style", "display:none;"));
					main.appendChild(resultContainer);
				}
			});
		}
		static createStatusIconForList(executionResults: PrintApi.ExecutionResult[], allJobsComplete: string) {
			var icon = "octicon-server";
			if (allJobsComplete == "true") {
				for (var i = 0; i < executionResults.length; i++) {
					icon = "octicon-check";
					if (executionResults[i].result != "0") {
						icon = "octicon-x";
						i = executionResults.length;
					}
				}
			}
			return HtmlBuilder.createElement("span", "", "class", "octicon " + icon);
		}
		static createStatusIcon(result: string) {
			var icon = "octicon-check";
			if (result != "0")
				icon = "octicon-x";
			return HtmlBuilder.createElement("span", "", "class", "octicon " + icon);
		}
	}
}
{'fraction_non_alphanumeric': 0.15247955010224948, 'fraction_numerical': 0.004217791411042945, 'mean_word_length': 4.670289855072464, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, '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': '6585528', 'n_tokens_mistral': 2709, 'n_tokens_neox': 2275, 'n_words': 410}