<commit_before>// A very simple meteor app built out from the leaderboard example

Projects = new Meteor.Collection("projects");

if (Meteor.is_client) {
	// link each template value to a db query - meteor propagates any changes to the underlying data in real time, automatically
	// (note. this could perhaps be improved by reducing the number of queries and not having so many separate statements?)
	Template.statusboard.projects = function () {
		return Projects.find({}, {sort: {target: -1, status: 1}});
	};

	Template.statusboard.selected_name = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.name;
	};

	Template.statusboard.selected_status = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.status;
	};

	Template.statusboard.selected_release = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.release;
	};
	
	Template.statusboard.selected_target = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.target;
	};

	Template.statusboard.selected_comment = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.comment;
	};

	Template.statusboard.selected_risk = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.risk;
	};
	
	Template.project.selected = function () {
		return Session.equals("selected_project", this._id) ? "selected" : '';
	};
	
	Template.statusboard.events = {
		// update project
		'click a.update': function () {
			Projects.update(Session.get("selected_project"), {
				name: $('#project_name_edit').val(),
				release: $('#project_release_edit').val(),
				target: parseInt($('#project_target_edit').val(), 10),
				comment: $('#project_comment_edit').val(),
				risk: $('#project_risk_edit').val(),
				status: $('#project_status_edit').val()
			});

			Session.set("selected_project", null);
		},
		// remove project
		'click a.remove': function() {
			var project = Projects.findOne(Session.get("selected_project"));
			Projects.remove({_id: project._id})
		},
		// insert a new project
		'click a.add': function () {
			var newName = $('#project_name').val();
			if (Validation.valid_name(newName)) {
				Projects.insert({
					name: newName
				})
				
				var project = Projects.findOne({name: newName});
				Session.set("selected_project", project._id);
			}
		},
		// nothing is selected
		'click a.cancel': function () {
			Session.set("selected_project", null);
		}
	};
	
	// on clicking a project, update the var which stores this
	Template.project.events = {
		'click': function () {
			Session.set("selected_project", this._id);
		}
	};
	
	// set the selected option for the status drop down
	var selectedStatus = Template.statusboard.selected_status;
	Handlebars.registerHelper('isStatusSelected', function(selectedStatus, optionValue) {
	  return selectedStatus == optionValue ? ' selected' : '';
	});
	
	// choose a colour for the status text
	Handlebars.registerHelper('getStatusColor', function(selectedStatus) {
		switch (selectedStatus) {
			case "GOOD" : {<commit_msg>Changed defaults for new projects<commit_after>// A very simple meteor app built out from the leaderboard example

Projects = new Meteor.Collection("projects");

if (Meteor.is_client) {
	// link each template value to a db query - meteor propagates any changes to the underlying data in real time, automatically
	// (note. this could perhaps be improved by reducing the number of queries and not having so many separate statements?)
	Template.statusboard.projects = function () {
		return Projects.find({}, {sort: {target: -1, status: 1}});
	};

	Template.statusboard.selected_name = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.name;
	};

	Template.statusboard.selected_status = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.status;
	};

	Template.statusboard.selected_release = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.release;
	};
	
	Template.statusboard.selected_target = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.target;
	};

	Template.statusboard.selected_comment = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.comment;
	};

	Template.statusboard.selected_risk = function () {
		var project = Projects.findOne(Session.get("selected_project"));
		return project && project.risk;
	};
	
	Template.project.selected = function () {
		return Session.equals("selected_project", this._id) ? "selected" : '';
	};
	
	Template.statusboard.events = {
		// update project
		'click a.update': function () {
			Projects.update(Session.get("selected_project"), {
				name: $('#project_name_edit').val(),
				release: $('#project_release_edit').val(),
				target: parseInt($('#project_target_edit').val(), 10),
				comment: $('#project_comment_edit').val(),
				risk: $('#project_risk_edit').val(),
				status: $('#project_status_edit').val()
			});

			Session.set("selected_project", null);
		},
		// remove project
		'click a.remove': function() {
			var project = Projects.findOne(Session.get("selected_project"));
			Projects.remove({_id: project._id})
		},
		// insert a new project
		'click a.add': function () {
			var newName = $('#project_name').val();
			if (Validation.valid_name(newName)) {
				Projects.insert({
					name: newName,
					target: 0,
					status: "IN PROGRESS"
				})
				
				var project = Projects.findOne({name: newName});
				Session.set("selected_project", project._id);
			}
		},
		// nothing is selected
		'click a.cancel': function () {
			Session.set("selected_project", null);
		}
	};
	
	// on clicking a project, update the var which stores this
	Template.project.events = {
		'click': function () {
			Session.set("selected_project", this._id);
		}
	};
	
	// set the selected option for the status drop down
	var selectedStatus = Template.statusboard.selected_status;
	Handlebars.registerHelper('isStatusSelected', function(selectedStatus, optionValue) {
	  return selectedStatus == optionValue ? ' selected' : '';
	});
	
	// choose a colour for the status text
	Handlebars.registerHelper('getStatusColor', function(selectedStatus) {
		switch (selectedStatus) {
			case "GOOD" : {
{'fraction_non_alphanumeric': 0.14380865879503482, 'fraction_numerical': 0.0013623978201634877, 'mean_word_length': 4.294070512820513, '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': '1498104', 'n_tokens_mistral': 2129, 'n_tokens_neox': 1861, 'n_words': 463}