<commit_before><?php

class BatchJobFilter extends baseObjectFilter
{
	const JOB_TYPE_AND_SUB_TYPE_MAIN_DELIMITER = ';';
	const JOB_TYPE_AND_SUB_TYPE_TYPE_DELIMITER = ':';
	const JOB_TYPE_AND_SUB_TYPE_SUB_DELIMITER = ',';
	
	public function init ()
	{
		// TODO - should separate the schema of the fields from the actual values
		// or can use this to set default valuse
		$this->fields = kArray::makeAssociativeDefaultValue ( array (
			"_eq_id" , 
			"_gte_id" ,
			"_eq_status" ,
			"_in_status" ,
			"_eq_job_type" ,
			"_in_job_type" ,
			"_notin_job_type" ,
			"_gte_created_at" , 
			"_lte_created_at" ,
			"_eq_job_sub_type",
			"_in_job_sub_type",
			"_in_work_group_id",
			"_lt_file_size",
			"_gt_file_size",
			"_in_on_stress_divert_to",
			"_eq_entry_id",
			"_eq_partner_id",
			"_in_partner_id",
			"_gte_queue_time",
			"_lte_queue_time",
			"_gte_finish_time",
			"_lte_finish_time",
			"_gte_priority",
			"_lte_priority",
			"_in_err_type",
		
			"_in_job_type_and_sub_type",
			) , NULL );
			
		$this->allowed_order_fields = array ( "created_at" , "execution_attempts" );
			
	}

	public function describe() 
	{
		return 
			array (
				"display_name" => "BatchJobFilter",
				"desc" => ""
			);
	}
	
	// TODO - move to base class, all that should stay here is the peer class, not the logic of the field translation !
	// The base class should invoke $peek_class::translateFieldName( $field_name , BasePeer::TYPE_FIELDNAME , BasePeer::TYPE_COLNAME );
	public function getFieldNameFromPeer ( $field_name )
	{
		$res = BatchJobPeer::translateFieldName( $field_name , $this->field_name_translation_type , BasePeer::TYPE_COLNAME );
		return $res;
	}

	public function getIdFromPeer (  )
	{
		return BatchJobPeer::ID;
	}

	
	public function attachToFinalCriteria ( Criteria $criteria )
	{
		$jobTypeAndSubTypeIn = $this->get("_in_job_type_and_sub_type");
		if ($jobTypeAndSubTypeIn !== null)
		{

			$finalTypesAndSubTypes = array();
			$arr = explode(self::JOB_TYPE_AND_SUB_TYPE_MAIN_DELIMITER, $jobTypeAndSubTypeIn);
			foreach($arr as $jobTypeIn)
			{
				list($jobType, $jobSubTypes) = explode(self::JOB_TYPE_AND_SUB_TYPE_TYPE_DELIMITER, $jobTypeIn);
				$finalTypesAndSubTypes[$jobType] = $jobSubTypes;
			}
			
			if(count($finalTypesAndSubTypes))
			{
				$mainCriterion = null;

				foreach($finalTypesAndSubTypes as $finalJobType => $finalSubTypes)
				{
					if($mainCriterion)
					{
						if(strlen(trim($finalSubTypes)))
						{
							$finalSubTypesArr = explode(self::JOB_TYPE_AND_SUB_TYPE_SUB_DELIMITER, $finalSubTypes);<commit_msg>Dynamic job types should be translated to core<commit_after><?php

class BatchJobFilter extends baseObjectFilter
{
	const JOB_TYPE_AND_SUB_TYPE_MAIN_DELIMITER = ';';
	const JOB_TYPE_AND_SUB_TYPE_TYPE_DELIMITER = ':';
	const JOB_TYPE_AND_SUB_TYPE_SUB_DELIMITER = ',';
	
	public function init ()
	{
		// TODO - should separate the schema of the fields from the actual values
		// or can use this to set default valuse
		$this->fields = kArray::makeAssociativeDefaultValue ( array (
			"_eq_id" , 
			"_gte_id" ,
			"_eq_status" ,
			"_in_status" ,
			"_eq_job_type" ,
			"_in_job_type" ,
			"_notin_job_type" ,
			"_gte_created_at" , 
			"_lte_created_at" ,
			"_eq_job_sub_type",
			"_in_job_sub_type",
			"_in_work_group_id",
			"_lt_file_size",
			"_gt_file_size",
			"_in_on_stress_divert_to",
			"_eq_entry_id",
			"_eq_partner_id",
			"_in_partner_id",
			"_gte_queue_time",
			"_lte_queue_time",
			"_gte_finish_time",
			"_lte_finish_time",
			"_gte_priority",
			"_lte_priority",
			"_in_err_type",
		
			"_in_job_type_and_sub_type",
			) , NULL );
			
		$this->allowed_order_fields = array ( "created_at" , "execution_attempts" );
			
	}

	public function describe() 
	{
		return 
			array (
				"display_name" => "BatchJobFilter",
				"desc" => ""
			);
	}
	
	// TODO - move to base class, all that should stay here is the peer class, not the logic of the field translation !
	// The base class should invoke $peek_class::translateFieldName( $field_name , BasePeer::TYPE_FIELDNAME , BasePeer::TYPE_COLNAME );
	public function getFieldNameFromPeer ( $field_name )
	{
		$res = BatchJobPeer::translateFieldName( $field_name , $this->field_name_translation_type , BasePeer::TYPE_COLNAME );
		return $res;
	}

	public function getIdFromPeer (  )
	{
		return BatchJobPeer::ID;
	}

	
	public function attachToFinalCriteria ( Criteria $criteria )
	{
		$jobTypeAndSubTypeIn = $this->get("_in_job_type_and_sub_type");
		if ($jobTypeAndSubTypeIn !== null)
		{

			$finalTypesAndSubTypes = array();
			$arr = explode(self::JOB_TYPE_AND_SUB_TYPE_MAIN_DELIMITER, $jobTypeAndSubTypeIn);
			foreach($arr as $jobTypeIn)
			{
				list($jobType, $jobSubTypes) = explode(self::JOB_TYPE_AND_SUB_TYPE_TYPE_DELIMITER, $jobTypeIn);
				
				if(class_exists('KalturaBatchJobType'))
					$jobType = KalturaBatchJobType::getCoreValue($jobType);
					
				$finalTypesAndSubTypes[$jobType] = $jobSubTypes;
			}
			
			if(count($finalTypesAndSubTypes))
			{
				$mainCriterion = null;

				foreach($finalTypesAndSubTypes as $finalJobType => $finalSubTypes)
				{
					if($mainCriterion)
					{
						if(strlen(trim($finalSubTypes)))
						{
							$finalSubTypesArr = explode(self::JOB_TYPE_AND_SUB_TYPE_SUB_DELIMITER, $finalSubTypes);
{'fraction_non_alphanumeric': 0.11668876681189619, 'fraction_numerical': 0.0, 'mean_word_length': 4.258964143426295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '2497194', 'n_tokens_mistral': 2281, 'n_tokens_neox': 1922, 'n_words': 325}