<commit_before><?php
class customer_BirthdayCustomerFilter extends f_persistentdocument_DocumentFilterImpl
{
	public function __construct()
	{
		$parameters = array();
		
		$info = new BeanPropertyInfoImpl('count', 'Integer');
		$countParameter = new f_persistentdocument_DocumentFilterValueParameter($info);
		$parameters['count'] = $countParameter;
		
		$this->setParameters($parameters);
	}

	
	/**
	 * @return String
	 */
	public static function getDocumentModelName()
	{
		return 'modules_customer/customer';
	}

	/**
	 * @return f_persistentdocument_criteria_Query
	 */
	public function getQuery()
	{
		$count = $this->getParameter('count')->getValueForQuery();
		$todayPlusCount = date_Calendar::getInstance()->now();
		$todayPlusCount->add(date_Calendar::DAY,$count);
		$today = date_Calendar::getInstance()->now();
		$todayDayNumber = ($today->getMonth()*31 + $today->getDay());
		$todayPlusCountDayNumber = ($todayPlusCount->getMonth()*31 + $todayPlusCount->getDay());
		
		
		if (($todayDayNumber + $count) > 403)
		{
			return customer_CustomerService::getInstance()->createQuery()->add(Restrictions::orExp(
				Restrictions::ge('birthdayDayNumber', $todayDayNumber), 
				Restrictions::le('birthdayDayNumber', $todayPlusCountDayNumber)
			));
		}
		else 
		{
			return customer_CustomerService::getInstance()->createQuery()->add(Restrictions::between('birthdayDayNumber', $todayDayNumber, $todayPlusCountDayNumber));	
		}
		
	}
	
	/**
	 * @param customer_persistentdocument_customer $value
	 */
	public function checkValue($value)
	{	
		if ($value instanceof customer_persistentdocument_customer)
		{
			$birthdayDayNumber = $value->getBirthdayDayNumber();
			if ($birthdayDayNumber !== null)
			{
				$count = $this->getParameter('count');
				$todayPlusCount = date_Calendar::getInstance()->now();
				$todayPlusCount->add(date_Calendar::DAY,$count);
				$today = date_Calendar::getInstance()->now();
				$todayDayNumber = ($today->getMonth()*31 + $today->getDay());
				$todayPlusCountDayNumber = ($todayPlusCount->getMonth()*31 + $todayPlusCount->getDay()); 
				
				if (($todayDayNumber + $count) > 403)
				{
					if ((($birthdayDayNumber >= $todayDayNumber) && ($birthdayDayNumber <= 403)) ||	(($birthdayDayNumber >= 32) && ($birthdayDayNumber <= $todayPlusCountDayNumber)))
					{
						return true;
					}
				}
				else if (($birthdayDayNumber >= $todayDayNumber) && ($birthdayDayNumber < $todayPlusCountDayNumber))
				{
					return true;
				}
			}
		}
		return false;
	}
}<commit_msg>[FIX]Optimise Birthday filter<commit_after><?php
class customer_BirthdayCustomerFilter extends f_persistentdocument_DocumentFilterImpl
{
	public function __construct()
	{
		$parameters = array();
		
		$info = new BeanPropertyInfoImpl('count', 'Integer');
		$countParameter = new f_persistentdocument_DocumentFilterValueParameter($info);
		$parameters['count'] = $countParameter;
		
		$this->setParameters($parameters);
	}

	
	/**
	 * @return String
	 */
	public static function getDocumentModelName()
	{
		return 'modules_customer/customer';
	}

	/**
	 * @return f_persistentdocument_criteria_Query
	 */
	public function getQuery()
	{
		$count = $this->getParameter('count')->getValueForQuery();
		$todayPlusCount = date_Calendar::now();
		$todayPlusCount->add(date_Calendar::DAY,$count);
		$today = date_Calendar::now();
		$todayDayNumber = ($today->getMonth()*31 + $today->getDay());
		$todayPlusCountDayNumber = ($todayPlusCount->getMonth()*31 + $todayPlusCount->getDay());
		
		
		if (($todayDayNumber + $count) > 403)
		{
			return customer_CustomerService::getInstance()->createQuery()->add(Restrictions::orExp(
				Restrictions::ge('birthdayDayNumber', $todayDayNumber), 
				Restrictions::le('birthdayDayNumber', $todayPlusCountDayNumber)
			));
		}
		else 
		{
			return customer_CustomerService::getInstance()->createQuery()->add(Restrictions::between('birthdayDayNumber', $todayDayNumber, $todayPlusCountDayNumber));	
		}
		
	}
	
	/**
	 * @param customer_persistentdocument_customer $value
	 */
	public function checkValue($value)
	{	
		if ($value instanceof customer_persistentdocument_customer)
		{
			$birthdayDayNumber = $value->getBirthdayDayNumber();
			if ($birthdayDayNumber !== null)
			{
				$count = $this->getParameter('count');
				$todayPlusCount = date_Calendar::now();
				$todayPlusCount->add(date_Calendar::DAY,$count);
				$today = date_Calendar::now();
				$todayDayNumber = ($today->getMonth()*31 + $today->getDay());
				$todayPlusCountDayNumber = ($todayPlusCount->getMonth()*31 + $todayPlusCount->getDay()); 
				
				if (($todayDayNumber + $count) > 403)
				{
					if ((($birthdayDayNumber >= $todayDayNumber) && ($birthdayDayNumber <= 403)) ||	(($birthdayDayNumber >= 32) && ($birthdayDayNumber <= $todayPlusCountDayNumber)))
					{
						return true;
					}
				}
				else if (($birthdayDayNumber >= $todayDayNumber) && ($birthdayDayNumber < $todayPlusCountDayNumber))
				{
					return true;
				}
			}
		}
		return false;
	}
}
{'fraction_non_alphanumeric': 0.15208090237261765, 'fraction_numerical': 0.007390120575651498, 'mean_word_length': 4.168844221105528, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 55, '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': '2137261', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1520, 'n_words': 230}