<commit_before><?php
namespace application\nutsNBolts\model
{
	use application\nutsNBolts\model\base\NodeMap as NodeMapBase;
	
	class NodeMap extends NodeMapBase	
	{
		public function getNodesForPath($path)
		{
			$path=rtrim($path,'/');
			if (empty($path))
			{
				$path='/';
			}
			//Is there a URL matching this exact path?
			$query=<<<SQL
			SELECT node.*
			FROM node
			LEFT JOIN node_map ON node_map.node_id=node.id
			WHERE node_map.url=?;
SQL;
			if ($this->db->select($query,array($path)))
			{
				$records=$this->db->result('assoc');
				$this->attachParts($records);
				return $records;
			}
			
			//No, so lets see if we can find one that has a wildcard.
			
			$pathParts	=explode('/',$path);
			$checks		=array();
			$currentPath='';
			for ($i=0,$j=count($pathParts); $i<$j; $i++)
			{
				if (!empty($pathParts[$i]))
				{
					$currentPath.='/';
				}
				$currentPath.=$pathParts[$i];
				$checks[]=$currentPath.'/\\\\*';
			}
			$regexp='('.implode(')|(',$checks).')';
			$query=<<<SQL
			SELECT node.*
			FROM node
			LEFT JOIN node_map ON node_map.node_id=node.id
			WHERE node_map.url REGEXP('^{$regexp}\$');
SQL;
			if ($this->db->select($query))
			{
				$records=$this->db->result('assoc');
				$this->attachParts($records);
				return $records;
			}
			return false;
		}
		
		private function attachParts(&$records)
		{
			for ($i=0,$j=count($records); $i<$j; $i++)
			{
				$query=<<<SQL
				SELECT node_part.value,content_part.ref
				FROM node_part
				LEFT JOIN content_part ON content_part.id=node_part.content_part_id
				WHERE node_part.node_id=?
				ORDER BY node_id DESC;
SQL;
				if ($this->db->select($query,array($records[$i]['id'])))<commit_msg>testing the results on the nodemap<commit_after><?php
namespace application\nutsNBolts\model
{
	use application\nutsNBolts\model\base\NodeMap as NodeMapBase;
	
	class NodeMap extends NodeMapBase	
	{
		public function getNodesForPath($path)
		{
			$path=rtrim($path,'/');
			if (empty($path))
			{
				$path='/';
			}
			//Is there a URL matching this exact path?
			$query=<<<SQL
			SELECT node.*
			FROM node
			LEFT JOIN node_map ON node_map.node_id=node.id
			WHERE node_map.url=?;
SQL;
			if ($this->db->select($query,array($path)))
			{
				$records=$this->db->result('assoc');
				print_r($records);
				die();
				$this->attachParts($records);
				return $records;
			}
			
			//No, so lets see if we can find one that has a wildcard.
			
			$pathParts	=explode('/',$path);
			$checks		=array();
			$currentPath='';
			for ($i=0,$j=count($pathParts); $i<$j; $i++)
			{
				if (!empty($pathParts[$i]))
				{
					$currentPath.='/';
				}
				$currentPath.=$pathParts[$i];
				$checks[]=$currentPath.'/\\\\*';
			}
			$regexp='('.implode(')|(',$checks).')';
			$query=<<<SQL
			SELECT node.*
			FROM node
			LEFT JOIN node_map ON node_map.node_id=node.id
			WHERE node_map.url REGEXP('^{$regexp}\$');
SQL;
			if ($this->db->select($query))
			{
				$records=$this->db->result('assoc');
				print_r($records);
				die();				
				$this->attachParts($records);
				return $records;
			}
			return false;
		}
		
		private function attachParts(&$records)
		{
			for ($i=0,$j=count($records); $i<$j; $i++)
			{
				$query=<<<SQL
				SELECT node_part.value,content_part.ref
				FROM node_part
				LEFT JOIN content_part ON content_part.id=node_part.content_part_id
				WHERE node_part.node_id=?
				ORDER BY node_id DESC;
SQL;
				if ($this->db->select($query,array($records[$i]['id'])))
{'fraction_non_alphanumeric': 0.18809318377911993, 'fraction_numerical': 0.0011504170261719873, 'mean_word_length': 3.272727272727273, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '4964919', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1264, 'n_words': 250}