<commit_before><?php
/**
 *
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   2012-2013 <NAME>
 * @license     GNU General Public License http://www.gnu.org/licenses/gpl.txt
 * @version     $Id$
 */
namespace Channel;

/**
 *
 */
class Estimate extends \Channel {}
<commit_msg>Draft for production estimation channel<commit_after><?php
/**
 *
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   2012-2013 <NAME>
 * @license     GNU General Public License http://www.gnu.org/licenses/gpl.txt
 * @version     $Id$
 */
namespace Channel;

/**
 *
 */
class Estimate extends \Channel {

	/**
	 *
	 */
	public function read( $request, $attributes=FALSE ) {

		$this->before_read($request);

		// make sure, only until now :-)
		$this->end = min($this->end, time());

		// Buffer $this->db->TimeStep, at least 60 seconds
		$TimeStep = max(60, $this->db->TimeStep);

		// Search for estimate, 1st for exact day
		$data  = explode("\n", $this->comment);
		$dstart = date('m-d', $this->start);
		$mstart = date('d', $this->start);
		$dend   = date('m-d', $this->end);
		$mend   = date('d', $this->end);
		foreach ($data as $line) {
			$line = explode(':', $line, 2);
			if (trim($line[0]) == $dstart) $estimate[1] = $line[1];
			elseif (trim($line[0]) == $mstart) $estimate[1] = $line[1];
			if (trim($line[0]) == $dend) $estimate[2] = $line[1];
			elseif (trim($line[0]) == $mend) $estimate[2] = $line[1];
		}

		$result = new \Buffer;

		if (!isset($estimate)) return $result; // Return empty result

		// Calc sunrise & sunset


		// Align start to full minutes
		$ts = floor($this->start / $TimeStep) * $TimeStep;

		$result->write(array(
			'datetime'    => date('Y-m-d H:i:s', $ts),
			'timestamp'   => $ts,
			'data'        => +$estimate[1],
			'min'         => +$estimate[1],
			'max'         => +$estimate[1],
			'count'       => 1,
			'timediff'    => 0,
			'consumption' => 0
		), $this->start);

		// Align end to full minutes
		$ts = floor($this->end / $TimeStep) * $TimeStep;

		$result->write(array(
			'datetime'    => date('Y-m-d H:i:s', $ts),
			'timestamp'   => $ts,
			'data'        => +$estimate[2],
			'min'         => +$estimate[2],
			'max'         => +$estimate[2],
			'count'       => 1,
			'timediff'    => $this->end-$this->start,
			'consumption' => 0
		), $this->end);

		return $this->after_read($result, $attributes);
	}

}

{'fraction_non_alphanumeric': 0.21976149914821125, 'fraction_numerical': 0.019165247018739354, 'mean_word_length': 2.813311688311688, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5184305', 'n_tokens_mistral': 976, 'n_tokens_neox': 877, 'n_words': 193}