<commit_before>RangesTracker = require "./RangesTracker"
logger = require "logger-sharelatex"

module.exports = RangesManager =
	MAX_COMMENTS: 500
	MAX_CHANGES: 500

	applyUpdate: (project_id, doc_id, entries = {}, updates = [], callback = (error, new_entries) ->) ->
		{changes, comments} = entries
		logger.log {changes, comments, updates}, "applying updates to ranges"
		rangesTracker = new RangesTracker(changes, comments)
		for update in updates
			rangesTracker.track_changes = !!update.meta.tc
			if !!update.meta.tc
				rangesTracker.setIdSeed(update.meta.tc)
			for op in update.op
				rangesTracker.applyOp(op, { user_id: update.meta?.user_id })
		
		if rangesTracker.changes?.length > RangesManager.MAX_CHANGES or rangesTracker.comments?.length > RangesManager.MAX_COMMENTS
			return callback new Error("too many comments or tracked changes")

		response = RangesManager._getRanges rangesTracker
		logger.log {response}, "applied updates to ranges"
		callback null, response

	acceptChange: (change_id, ranges, callback = (error, ranges) ->) ->
		{changes, comments} = ranges
		logger.log {changes, comments, change_id}, "accepting change in ranges"<commit_msg>Increase change limit to 1000<commit_after>RangesTracker = require "./RangesTracker"
logger = require "logger-sharelatex"

module.exports = RangesManager =
	MAX_COMMENTS: 500
	MAX_CHANGES: 1000

	applyUpdate: (project_id, doc_id, entries = {}, updates = [], callback = (error, new_entries) ->) ->
		{changes, comments} = entries
		logger.log {changes, comments, updates}, "applying updates to ranges"
		rangesTracker = new RangesTracker(changes, comments)
		for update in updates
			rangesTracker.track_changes = !!update.meta.tc
			if !!update.meta.tc
				rangesTracker.setIdSeed(update.meta.tc)
			for op in update.op
				rangesTracker.applyOp(op, { user_id: update.meta?.user_id })
		
		if rangesTracker.changes?.length > RangesManager.MAX_CHANGES or rangesTracker.comments?.length > RangesManager.MAX_COMMENTS
			return callback new Error("too many comments or tracked changes")

		response = RangesManager._getRanges rangesTracker
		logger.log {response}, "applied updates to ranges"
		callback null, response

	acceptChange: (change_id, ranges, callback = (error, ranges) ->) ->
		{changes, comments} = ranges
		logger.log {changes, comments, change_id}, "accepting change in ranges"
{'fraction_non_alphanumeric': 0.1084286319356205, 'fraction_numerical': 0.007200338839474798, 'mean_word_length': 4.890274314214464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3689354', 'n_tokens_mistral': 782, 'n_tokens_neox': 695, 'n_words': 193}