<commit_before>

import { ColourCache } from './ColourCache';

var map = [];
var selectedSection = 0;

var SurveyColours = {};

SurveyColours.clearMap = function () {

	map = [];
	selectedSection = 0;

};

SurveyColours.getSurveyColour = function ( surveyId ) {

	var surveyColours = ColourCache.survey;

	return surveyColours[ surveyId % surveyColours.length ];

};

SurveyColours.getSurveyColourMap = function ( surveyTree, newSelectedSection ) {

	if ( selectedSection === newSelectedSection && map.length > 0 ) {

		// use cached mapping
		return map;

	}

	map = [];
	selectedSection = newSelectedSection;

	var survey = ( selectedSection === 0 ) ? surveyTree.id : selectedSection;

	// create mapping of survey id to colour
	// map each child id _and_ all its lower level survey ids to the same colour

	var subTree = surveyTree.findById( survey );

	var colour = this.getSurveyColour( survey );

	_addMapping( subTree );

	var children = subTree.children;

	for ( var i = 0, l = children.length; i < l; i++ ) {

		var childId = children[ i ].id;

		subTree = surveyTree.findById( childId );

		colour = this.getSurveyColour( childId );

		subTree.traverse( _addMapping );

	}

	return map;

	function _addMapping ( node ) {

		// only add values for sections - not stations
		if ( node.p === undefined ) map[ node.id ] = colour;

	}

};

export { SurveyColours };<commit_msg>avoid singel colour surveys if possible<commit_after>

import { ColourCache } from './ColourCache';

var map = [];
var selectedSection = 0;

var SurveyColours = {};

SurveyColours.clearMap = function () {

	map = [];
	selectedSection = 0;

};

SurveyColours.getSurveyColour = function ( surveyId ) {

	var surveyColours = ColourCache.survey;

	return surveyColours[ surveyId % surveyColours.length ];

};

SurveyColours.getSurveyColourMap = function ( surveyTree, newSelectedSection ) {

	if ( selectedSection === newSelectedSection && map.length > 0 ) {

		// use cached mapping
		return map;

	}

	map = [];
	selectedSection = newSelectedSection;

	var survey = ( selectedSection === 0 ) ? surveyTree.id : selectedSection;

	// create mapping of survey id to colour
	// map each child id _and_ all its lower level survey ids to the same colour

	var subTree = surveyTree.findById( survey );

	var colour = this.getSurveyColour( survey );

	_addMapping( subTree );

	var children = subTree.children;

	while ( children.length === 1 ) {

		subTree = children[ 0 ];
		_addMapping( subTree );
		children = subTree.children;

	}

	for ( var i = 0, l = children.length; i < l; i++ ) {

		var childId = children[ i ].id;

		subTree = surveyTree.findById( childId );

		colour = this.getSurveyColour( childId );

		subTree.traverse( _addMapping );

	}

	return map;

	function _addMapping ( node ) {

		// only add values for sections - not stations
		if ( node.p === undefined ) map[ node.id ] = colour;

	}

};

export { SurveyColours };
{'fraction_non_alphanumeric': 0.11595197255574614, 'fraction_numerical': 0.00411663807890223, 'mean_word_length': 3.55625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4094764', 'n_tokens_mistral': 991, 'n_tokens_neox': 907, 'n_words': 269}