<commit_before><?php

namespace App\Model;

use Kdyby\RabbitMq\Connection;
use Kdyby\RabbitMq\IConsumer;
use Kdyby\Monolog\Logger;
use Nette;
use PhpAmqpLib\Message\AMQPMessage;
use Symfony\Component\Process\Process;



/**
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class Builder extends Nette\Object implements IConsumer
{

	/**
	 * @var string
	 */
	private $outputDir;

	/**
	 * @var string
	 */
	private $binFile;

	/**
	 * @var PackageManager
	 */
	private $packages;

	/**
	 * @var Connection
	 */
	private $rabbit;

	/**
	 * @var Logger
	 */
	private $logger;



	public function __construct($outputDir, $binFile, PackageManager $packages, Connection $rabbit, Logger $logger)
	{
		$this->outputDir = realpath($outputDir);
		$this->binFile = realpath($binFile);
		$this->packages = $packages;
		$this->rabbit = $rabbit;
		$this->logger = $logger->channel('satis-builder');
	}



	public function enqueueBuild()
	{
		$this->rabbit->getProducer('satisBuild')
			->publish(Nette\Utils\Json::encode(['at' => new \DateTime()]));
	}



	public function process($message)
	{
		if (!$message instanceof AMQPMessage) {
			return FALSE;
		}

		if (!is_array($request = Nette\Utils\Json::decode($message->body))) {
			return FALSE;
		}

		$process = $this->build();

		if (!$process->isSuccessful()) {
			$this->logger->addWarning('Build of satis package has failed');

		} else {
			$this->logger->addDebug('Build of satis package was successful');
		}

		return self::MSG_ACK;
	}<commit_msg>Fixed consumer<commit_after><?php

namespace App\Model;

use Kdyby\RabbitMq\Connection;
use Kdyby\RabbitMq\IConsumer;
use Kdyby\Monolog\Logger;
use Nette;
use Nette\Utils\Json;
use PhpAmqpLib\Message\AMQPMessage;
use Symfony\Component\Process\Process;



/**
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class Builder extends Nette\Object implements IConsumer
{

	/**
	 * @var string
	 */
	private $outputDir;

	/**
	 * @var string
	 */
	private $binFile;

	/**
	 * @var PackageManager
	 */
	private $packages;

	/**
	 * @var Connection
	 */
	private $rabbit;

	/**
	 * @var Logger
	 */
	private $logger;



	public function __construct($outputDir, $binFile, PackageManager $packages, Connection $rabbit, Logger $logger)
	{
		$this->outputDir = realpath($outputDir);
		$this->binFile = realpath($binFile);
		$this->packages = $packages;
		$this->rabbit = $rabbit;
		$this->logger = $logger->channel('satis-builder');
	}



	public function enqueueBuild()
	{
		$this->rabbit->getProducer('satisBuild')
			->publish(Json::encode(['at' => new \DateTime()]));
	}



	public function process($message)
	{
		if (!$message instanceof AMQPMessage) {
			return FALSE;
		}

		if (!$request = Json::decode($message->body, Json::FORCE_ARRAY)) {
			return FALSE;
		}

		$process = $this->build();

		if (!$process->isSuccessful()) {
			$this->logger->addWarning('Build of satis package has failed');

		} else {
			$this->logger->addDebug('Build of satis package was successful');
		}

		return self::MSG_ACK;
	}
{'fraction_non_alphanumeric': 0.1675496688741722, 'fraction_numerical': 0.0, 'mean_word_length': 3.9121951219512194, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 49, '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': '2185762', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1005, 'n_words': 218}