<commit_before><?php
 
/**
 * This class is the basic implemenation for quering Entry Total report.
 * If you need more complex behavior - please inherit this class
 */
class LiveReportEntryQueryEngine extends LiveReportEngine {
	
	protected $title;
	protected $printResult;
	protected $timeFrame;
	protected $fieldName;
	protected $defaultVal = array(0); // If didn't retrieve any value - use this as default.

	public function LiveReportEntryQueryEngine($field, $timeFrame, $title = null, $printResult = true) {
		$this->fieldName = $field;
		$this->timeFrame = $timeFrame;
		$this->title = $title;
		$this->printResult = $printResult;
	}
	
	public function run($fp, array $args = array()) {
		$this->checkParams($args, array(LiveReportConstants::TIME_REFERENCE_PARAM, LiveReportConstants::IS_LIVE, LiveReportConstants::ENTRY_IDS));

		$reportType = KalturaLiveReportType::ENTRY_TOTAL;
		
		$filter = new KalturaLiveReportInputFilter();
		$filter->live =  $args[LiveReportConstants::IS_LIVE];
		$filter->toTime = $args[LiveReportConstants::TIME_REFERENCE_PARAM];
		$filter->fromTime = $args[LiveReportConstants::TIME_REFERENCE_PARAM] - $this->timeFrame;
		$filter->entryIds = $args[LiveReportConstants::ENTRY_IDS];

		$res = LiveReportQueryHelper::retrieveFromReport($reportType, $filter, null, "entryId", $this->fieldName);
		if(empty($res))
			$res = $this->defaultVal;
		
		if($this->printResult) {
			$msg = $this->title . LiveReportConstants::CELLS_SEPARATOR . implode(LiveReportConstants::CELLS_SEPARATOR, $res);
			fwrite($fp, $msg);
		}
		
		return $res;
	}
	
	public function getTitle() {
		return $this->title;<commit_msg>Use the default value only in case of print.<commit_after><?php
 
/**
 * This class is the basic implemenation for quering Entry Total report.
 * If you need more complex behavior - please inherit this class
 */
class LiveReportEntryQueryEngine extends LiveReportEngine {
	
	protected $title;
	protected $printResult;
	protected $timeFrame;
	protected $fieldName;
	protected $defaultVal = array(0); // If didn't retrieve any value - use this as default.

	public function LiveReportEntryQueryEngine($field, $timeFrame, $title = null, $printResult = true) {
		$this->fieldName = $field;
		$this->timeFrame = $timeFrame;
		$this->title = $title;
		$this->printResult = $printResult;
	}
	
	public function run($fp, array $args = array()) {
		$this->checkParams($args, array(LiveReportConstants::TIME_REFERENCE_PARAM, LiveReportConstants::IS_LIVE, LiveReportConstants::ENTRY_IDS));

		$reportType = KalturaLiveReportType::ENTRY_TOTAL;
		
		$filter = new KalturaLiveReportInputFilter();
		$filter->live =  $args[LiveReportConstants::IS_LIVE];
		$filter->toTime = $args[LiveReportConstants::TIME_REFERENCE_PARAM];
		$filter->fromTime = $args[LiveReportConstants::TIME_REFERENCE_PARAM] - $this->timeFrame;
		$filter->entryIds = $args[LiveReportConstants::ENTRY_IDS];

		$res = LiveReportQueryHelper::retrieveFromReport($reportType, $filter, null, "entryId", $this->fieldName);
		
		if($this->printResult) {
			if(empty($res))
				$res = $this->defaultVal;
			$msg = $this->title . LiveReportConstants::CELLS_SEPARATOR . implode(LiveReportConstants::CELLS_SEPARATOR, $res);
			fwrite($fp, $msg);
		}
		
		return $res;
	}
	
	public function getTitle() {
		return $this->title;
{'fraction_non_alphanumeric': 0.13299000302938505, 'fraction_numerical': 0.0006058770069675856, 'mean_word_length': 5.525691699604743, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '5396890', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1017, 'n_words': 227}