<commit_before>﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Rainbow.Filtering;
using Rainbow.Model;
using Rainbow.Storage;
using Sitecore.Configuration;
using Sitecore.Diagnostics;
using Unicorn.Configuration;
using Unicorn.Data.Dilithium.Data;
using Unicorn.Predicates;
// ReSharper disable TooWideLocalVariableScope

namespace Unicorn.Data.Dilithium
{
	public class DilithiumReactor
	{
		protected object SyncLock = new object();
		protected bool Initialized = false;

		private readonly IConfiguration[] _configurations;
		private List<DataCore> _dataCores; 

		public DilithiumReactor(IConfiguration[] configurations)
		{
			_configurations = configurations;
		}

		public IEnumerable<IItemData> GetByPath(string path, string database)
		{
			var cores = GetCores(database);

			var results = new List<IItemData>();
			foreach (var core in cores)
			{
				results.AddRange(core.GetByPath(path));
			}

			return results;
		}

		public IEnumerable<IItemData> GetChildren(IItemData item)
		{
			var dilithiumItem = item as DilithiumItemData;

			if(dilithiumItem == null) throw new InvalidOperationException($"Dilithium only knows how to get children of items returned from Dilithium. {item.GetType().FullName} is incompatible.");

			var cores = GetCores(item.DatabaseName);

			var results = new List<IItemData>();
			foreach (var core in cores)
			{
				results.AddRange(core.GetChildren(dilithiumItem));
			}

			return results;
		}

		public IItemData GetById(Guid id, string database)
		{
			var cores = GetCores(database);
			DilithiumItemData result;

			foreach (var core in cores)
			{
				result = core.GetById(id);
<commit_msg>Fix developer tab serialization which passes ItemData to dilithium and asks for children<commit_after>﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Rainbow.Filtering;
using Rainbow.Model;
using Rainbow.Storage;
using Sitecore.Configuration;
using Sitecore.Diagnostics;
using Unicorn.Configuration;
using Unicorn.Data.Dilithium.Data;
using Unicorn.Predicates;
// ReSharper disable TooWideLocalVariableScope

namespace Unicorn.Data.Dilithium
{
	public class DilithiumReactor
	{
		protected object SyncLock = new object();
		protected bool Initialized = false;

		private readonly IConfiguration[] _configurations;
		private List<DataCore> _dataCores; 

		public DilithiumReactor(IConfiguration[] configurations)
		{
			_configurations = configurations;
		}

		public IEnumerable<IItemData> GetByPath(string path, string database)
		{
			var cores = GetCores(database);

			var results = new List<IItemData>();
			foreach (var core in cores)
			{
				results.AddRange(core.GetByPath(path));
			}

			return results;
		}

		public IEnumerable<IItemData> GetChildren(IItemData item)
		{
			var dilithiumItem = item as DilithiumItemData;

			// if the item is not from Dilithium it will have to use its original data store to get children
			if (dilithiumItem == null) return item.GetChildren();

			var cores = GetCores(item.DatabaseName);

			var results = new List<IItemData>();
			foreach (var core in cores)
			{
				results.AddRange(core.GetChildren(dilithiumItem));
			}

			return results;
		}

		public IItemData GetById(Guid id, string database)
		{
			var cores = GetCores(database);
			DilithiumItemData result;

			foreach (var core in cores)
			{
				result = core.GetById(id);

{'fraction_non_alphanumeric': 0.0858416945373467, 'fraction_numerical': 0.0, 'mean_word_length': 4.530046224961479, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5281265', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1065, 'n_words': 299}