<commit_before><?php

class Services_Providers_Statistics {
	private $_oldestSpotAge = null;
	private $_nntpUpdate;
	private $_spotDao;

	private $_svcImageChart;
	private $_svcImageError;

	/*
	 * Constructor
	 *
	 * nntpUpdate is the last time an update of spots has occured
	 */
	function __construct(Dao_Spot $spotDao, Dao_Cache $cacheDao, $nntpUpdate) {
		$this->_spotDao = $spotDao;
		$this->_cacheDao = $cacheDao;
		$this->_nntpUpdate = $nntpUpdate;

		$this->_svcImageChart = new Services_Image_Chart();
		$this->_svcImageError = new Services_Image_Error();

		$this->getOldestSpotAge();
	} # ctor

	/*
	 * Create all statistics available
	 */
	public function createAllStatistics() {
		foreach ($this->getValidStatisticsLimits() as $limitValue => $limitName) {
			# Reset timelimit
			set_time_limit(60);

			foreach ($this->getValidStatisticsGraphs() as $graphValue => $graphName) {
				$this->renderStatImage($graphValue, $limitValue);
			} # foreach graph
		} # foreach limit
	} # createAllStatistics

	/*
	 * Returns an chart depending on who asks
	 */
	public function renderStatImage($statType, $dateLimit) {
		$graphs = $this->getValidStatisticsGraphs();
		$limits = $this->getValidStatisticsLimits();

		/*
		 * Requested invalid graphic settings, create an error image
		 */
		if ((!isset($graphs[$statType])) || (!isset($limits[$dateLimit]))) {
			return $this->_svcImageError->createErrorImage(400);
		} # if


		switch($statType) {<commit_msg>Increase AllStatistics timeout from 1 to 2 minutes. (Needed for Raspberry Pi with SQLite.)<commit_after><?php

class Services_Providers_Statistics {
	private $_oldestSpotAge = null;
	private $_nntpUpdate;
	private $_spotDao;

	private $_svcImageChart;
	private $_svcImageError;

	/*
	 * Constructor
	 *
	 * nntpUpdate is the last time an update of spots has occured
	 */
	function __construct(Dao_Spot $spotDao, Dao_Cache $cacheDao, $nntpUpdate) {
		$this->_spotDao = $spotDao;
		$this->_cacheDao = $cacheDao;
		$this->_nntpUpdate = $nntpUpdate;

		$this->_svcImageChart = new Services_Image_Chart();
		$this->_svcImageError = new Services_Image_Error();

		$this->getOldestSpotAge();
	} # ctor

	/*
	 * Create all statistics available
	 */
	public function createAllStatistics() {
		foreach ($this->getValidStatisticsLimits() as $limitValue => $limitName) {
			# Reset timelimit
			set_time_limit(120);

			foreach ($this->getValidStatisticsGraphs() as $graphValue => $graphName) {
				$this->renderStatImage($graphValue, $limitValue);
			} # foreach graph
		} # foreach limit
	} # createAllStatistics

	/*
	 * Returns an chart depending on who asks
	 */
	public function renderStatImage($statType, $dateLimit) {
		$graphs = $this->getValidStatisticsGraphs();
		$limits = $this->getValidStatisticsLimits();

		/*
		 * Requested invalid graphic settings, create an error image
		 */
		if ((!isset($graphs[$statType])) || (!isset($limits[$dateLimit]))) {
			return $this->_svcImageError->createErrorImage(400);
		} # if


		switch($statType) {
{'fraction_non_alphanumeric': 0.12974051896207583, 'fraction_numerical': 0.004324683965402528, 'mean_word_length': 4.610074626865671, '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': '2977879', 'n_tokens_mistral': 1055, 'n_tokens_neox': 951, 'n_words': 219}