<commit_before>window.sharksDB = {
	Models:{},
	Views:{},
	Collections:{},
	Map:{},
	Routers:{},
	Mediator: {},

	initialize : function () {
		sharksDB.Models.currentState = new sharksDB.Models.state();

		sharksDB.Mediator = _({}).extend(Backbone.Events); /* used to transfert view triggered events */

		sharksDB.Collections.speciesGroupsCollection =  new sharksDB.Collections.speciesGroups();
		sharksDB.Collections.speciesGroupsCollection.comparator = 'name';
		sharksDB.Collections.speciesCollection =  new sharksDB.Collections.species();
		sharksDB.Collections.speciesCollection.comparator =  'englishName';
		sharksDB.Collections.entitiesCollection =  new sharksDB.Collections.entities();
		sharksDB.Collections.entitiesCollection.comparator = 'acronym';
		sharksDB.Collections.countriesCollection =  new sharksDB.Collections.countries();
		sharksDB.Collections.countriesCollection.comparator = 'name';

		/* this is useless, just to keep track of properties used in the Map object */
		sharksDB.Map.map = undefined;
		sharksDB.Map.path = undefined;
		sharksDB.Map.projection = undefined;
		sharksDB.Map.projectionNatural = undefined;
		sharksDB.Map.projectionPolar = undefined;
		sharksDB.Map.backgroundLoaded = false; /* flag for background map loaded or not */
		sharksDB.Map.EURCountries = ["AUT","BEL","BGR","CYP","CZE","DNK","EST","FIN","FRA","DEU","GRC","HUN","IRL","ITA","LVA","LTU","LUX","MLT","NLD","POL","PRT","ROU","SVK","SVN","ESP","SWE","GBR", "HRV"]; /* iso_a3 list of members of European union */

		/* fetch from figis server the species general information and species groups complete information */
		function getSpecies (callback) {
			/* this var are used to synchonise results and make sure everything arrived before we call the callback from d3 queue */
			var groupsNb = -1; /* store the groups number to check we've fetch them all */
			var speciesFetch = false;
			var speciesGroupFetch = false;

			/* fetch general information on all species, details will be fetched on demand, it's enough to build the menu */
			sharksDB.Collections.speciesCollection.fetch({
				success : function () {
					if (speciesGroupFetch == true) {
						callback(null, sharksDB.Collections.speciesGroupsCollection);
					} else {
						speciesFetch = true;
					}
				}
			});

			/* fetch general information on groups and then details on an of them because we need it to build the dropdown menu */
			sharksDB.Collections.speciesGroupsCollection.fetch({
				success : function () {
					groupsNb = sharksDB.Collections.speciesGroupsCollection.length;
					/* loop all the group collection and fetch details (fish which are parts of the group) on them */
					sharksDB.Collections.speciesGroupsCollection.forEach(function(model) {
						model.url = sharksDB.Collections.speciesGroupsCollection.url+'/'+model.get('code'); /* assing an url to the mnodel to fetch from it */
						model.fetch({
							success: function () {
								groupsNb--;
								if (groupsNb==0) { /* check we've got them all */
									if (speciesFetch == true) { /* be sure species fetch already ended */<commit_msg>Group fetching is error resilient to server giving fake group list<commit_after>window.sharksDB = {
	Models:{},
	Views:{},
	Collections:{},
	Map:{},
	Routers:{},
	Mediator: {},

	initialize : function () {
		sharksDB.Models.currentState = new sharksDB.Models.state();

		sharksDB.Mediator = _({}).extend(Backbone.Events); /* used to transfert view triggered events */

		sharksDB.Collections.speciesGroupsCollection =  new sharksDB.Collections.speciesGroups();
		sharksDB.Collections.speciesGroupsCollection.comparator = 'name';
		sharksDB.Collections.speciesCollection =  new sharksDB.Collections.species();
		sharksDB.Collections.speciesCollection.comparator =  'englishName';
		sharksDB.Collections.entitiesCollection =  new sharksDB.Collections.entities();
		sharksDB.Collections.entitiesCollection.comparator = 'acronym';
		sharksDB.Collections.countriesCollection =  new sharksDB.Collections.countries();
		sharksDB.Collections.countriesCollection.comparator = 'name';

		/* this is useless, just to keep track of properties used in the Map object */
		sharksDB.Map.map = undefined;
		sharksDB.Map.path = undefined;
		sharksDB.Map.projection = undefined;
		sharksDB.Map.projectionNatural = undefined;
		sharksDB.Map.projectionPolar = undefined;
		sharksDB.Map.backgroundLoaded = false; /* flag for background map loaded or not */
		sharksDB.Map.EURCountries = ["AUT","BEL","BGR","CYP","CZE","DNK","EST","FIN","FRA","DEU","GRC","HUN","IRL","ITA","LVA","LTU","LUX","MLT","NLD","POL","PRT","ROU","SVK","SVN","ESP","SWE","GBR", "HRV"]; /* iso_a3 list of members of European union */

		/* fetch from figis server the species general information and species groups complete information */
		function getSpecies (callback) {
			/* this var are used to synchonise results and make sure everything arrived before we call the callback from d3 queue */
			var groupsNb = -1; /* store the groups number to check we've fetch them all */
			var speciesFetch = false;
			var speciesGroupFetch = false;

			/* fetch general information on all species, details will be fetched on demand, it's enough to build the menu */
			sharksDB.Collections.speciesCollection.fetch({
				success : function () {
					if (speciesGroupFetch == true) {
						callback(null, sharksDB.Collections.speciesGroupsCollection);
					} else {
						speciesFetch = true;
					}
				}
			});

			/* fetch general information on groups and then details on an of them because we need it to build the dropdown menu */
			sharksDB.Collections.speciesGroupsCollection.fetch({
				success : function () {
					groupsNb = sharksDB.Collections.speciesGroupsCollection.length;
					/* loop all the group collection and fetch details (fish which are parts of the group) on them */
					sharksDB.Collections.speciesGroupsCollection.forEach(function(model) {
						model.url = sharksDB.Collections.speciesGroupsCollection.url+'/'+model.get('code'); /* assing an url to the mnodel to fetch from it */
						model.fetch({
							success: function () {
								groupsNb--;
								if (groupsNb==0) { /* check we've got them all */
									if (speciesFetch == true) { /* be sure species fetch already ended */
										callback(null, sharksDB.Collections.speciesGroupsCollection);
									} else {
										speciesGroupFetch = true;
									}
								}
							},
							error: function () {
								console.log("Error fetching group model "+model.url);
								console.log("Skip this group");
								/* we must proceed anyway otherwise we will get stuck in the await all */
								groupsNb--;
								if (groupsNb==0) { /* check we've got them all */
									if (speciesFetch == true) { /* be sure species fetch already ended */
{'fraction_non_alphanumeric': 0.12107821475916924, 'fraction_numerical': 0.0013256738842244808, 'mean_word_length': 3.860415175375805, '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': '4577460', 'n_tokens_mistral': 2289, 'n_tokens_neox': 1881, 'n_words': 541}