<commit_before><?php
/**
 * @package plugins.elasticSearch
 * @subpackage lib.entitlement
 */

class kElasticPublicEntriesEntitlementDecorator implements IKalturaESearchEntryEntitlementDecorator
{

	public static function shouldContribute()
	{
		if(kEntryElasticEntitlement::$publicEntries || kEntryElasticEntitlement::$publicActiveEntries)
			return true;
		
		return false;
	}

	public static function getEntitlementCondition(array $params = array(), $fieldPrefix = '')
	{
		$condition = new kESearchBoolQuery();
		$statuses = $params['category_statues'];
		$statuses = array_map('elasticSearchUtils::formatCategoryEntryStatus', $statuses);
		$termsQuery = new kESearchTermsQuery("{$fieldPrefix}category_ids", $statuses);
		$condition->addToMustNot($termsQuery);
		return $condition;
	}

	public static function applyCondition(&$entryQuery, &$parentEntryQuery)
	{

		if(kEntryElasticEntitlement::$publicEntries)
			$params['category_statues'] = array(CategoryEntryStatus::ACTIVE, CategoryEntryStatus::PENDING);
		else if(kEntryElasticEntitlement::$publicActiveEntries)
			$params['category_statues'] = array(CategoryEntryStatus::ACTIVE);

		if($parentEntryQuery)
		{
			$condition = self::getEntitlementCondition($params, 'parent_entry.');
			$parentEntryQuery->addToShould($condition);
		}
		$condition = self::getEntitlementCondition($params);
		$entryQuery->addToShould($condition);
	}
}
<commit_msg>PLAT-9364: eSearch - fix field name in entitlement query<commit_after><?php
/**
 * @package plugins.elasticSearch
 * @subpackage lib.entitlement
 */

class kElasticPublicEntriesEntitlementDecorator implements IKalturaESearchEntryEntitlementDecorator
{

	public static function shouldContribute()
	{
		if(kEntryElasticEntitlement::$publicEntries || kEntryElasticEntitlement::$publicActiveEntries)
			return true;
		
		return false;
	}

	public static function getEntitlementCondition(array $params = array(), $fieldPrefix = '')
	{
		$condition = new kESearchBoolQuery();
		$statuses = $params['category_statues'];
		$statuses = array_map('elasticSearchUtils::formatCategoryEntryStatus', $statuses);
		$termsQuery = new kESearchTermsQuery($fieldPrefix . ESearchBaseCategoryEntryItem::CATEGORY_IDS_MAPPING_FIELD, $statuses);
		$condition->addToMustNot($termsQuery);
		return $condition;
	}

	public static function applyCondition(&$entryQuery, &$parentEntryQuery)
	{

		if(kEntryElasticEntitlement::$publicEntries)
			$params['category_statues'] = array(CategoryEntryStatus::ACTIVE, CategoryEntryStatus::PENDING);
		else if(kEntryElasticEntitlement::$publicActiveEntries)
			$params['category_statues'] = array(CategoryEntryStatus::ACTIVE);

		if($parentEntryQuery)
		{
			$condition = self::getEntitlementCondition($params, 'parent_entry.');
			$parentEntryQuery->addToShould($condition);
		}
		$condition = self::getEntitlementCondition($params);
		$entryQuery->addToShould($condition);
	}
}

{'fraction_non_alphanumeric': 0.12154696132596685, 'fraction_numerical': 0.0013812154696132596, 'mean_word_length': 7.571005917159764, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1572279', 'n_tokens_mistral': 934, 'n_tokens_neox': 870, 'n_words': 132}