<commit_before>jsio('from shared.javascript import Class, bind, forEach')

module.exports = Class(function() {
	
	this.init = function() {
		fin.query({ type: 'project' }, bind(this, '_onProjectsChange'))
		this._subs = {}
	}
	
	this._onProjectsChange = function(mutation) {
		var projectId = (mutation.sadd || mutation.srem),
			query = { type: 'task', status: {op: '!=', value: 'done'}, project: projectId }

		if (mutation.sadd) {
			this._subs[projectId] = fin.sum(query, bind(this, '_onRemainingTimeChange'))
		}
		if (mutation.srem) {
			fin.release(this._subs[projectId])
		}
	}
	
	this._onRemainingTimeChange = function(projectId, mutation, newTimeRemaining) {
		logger.log("Remaining time changed", projectId, newTimeRemaining)
		var newHistoryItem = { timestamp: new Date().getTime(), remaining_time: newTimeRemaining }
		fin.mutate(projectId, { property: 'burndown_history', rpush: newHistoryItem })
		fin.getItem(projectId).mutate()
	}
})<commit_msg>Remove unused log<commit_after>jsio('from shared.javascript import Class, bind, forEach')

module.exports = Class(function() {
	
	this.init = function() {
		fin.query({ type: 'project' }, bind(this, '_onProjectsChange'))
		this._subs = {}
	}
	
	this._onProjectsChange = function(mutation) {
		var projectId = (mutation.sadd || mutation.srem),
			query = { type: 'task', status: {op: '!=', value: 'done'}, project: projectId }

		if (mutation.sadd) {
			this._subs[projectId] = fin.sum(query, bind(this, '_onRemainingTimeChange'))
		}
		if (mutation.srem) {
			fin.release(this._subs[projectId])
		}
	}
	
	this._onRemainingTimeChange = function(projectId, mutation, newTimeRemaining) {
		var newHistoryItem = { timestamp: new Date().getTime(), remaining_time: newTimeRemaining }
		fin.mutate(projectId, { property: 'burndown_history', rpush: newHistoryItem })
		fin.getItem(projectId).mutate()
	}
})
{'fraction_non_alphanumeric': 0.15645161290322582, 'fraction_numerical': 0.0, 'mean_word_length': 5.022653721682848, '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': '5087735', 'n_tokens_mistral': 677, 'n_tokens_neox': 625, 'n_words': 121}