Example #1
0
	/**
	 * Returns our 'generator home made' Piwik_VisitorGenerator_Visit object.
	 *
	 * @return Piwik_VisitorGenerator_Visit
	 */
	protected function getNewVisitObject()
	{
		$ip = Piwik_Common::getRequestVar('cip', false);
		$visit = new Piwik_VisitorGenerator_Visit($ip);
		$visit->generateTimestamp();
		return $visit;
	}	
Example #2
0
	public function generateTimestamp()
	{
		self::$timestampToUse = max(@$this->visitorInfo['visit_last_action_time'],self::$timestampToUse);
		self::$timestampToUse += mt_rand(4,1840);
	}		
Example #3
0
	/**
	 * Launches the process and generates an exact number of nbVisitors
	 * For each visit, we setup the timestamp to the common timestamp
	 * Then we generate between 1 and nbActionsMaxPerVisit actions for this visit
	 * The generated actions will have a growing timestamp so it looks like a real visit
	 * 
	 * @param int The number of visits to generate
	 * @param int The maximum number of actions to generate per visit
	 * 
	 * @return int The number of total actions generated
	 */
	public function generate( $nbVisitors, $nbActionsMaxPerVisit )
	{
		$nbActionsTotal = 0;
		for($i = 0; $i < $nbVisitors; $i++)
		{
			$nbActions = mt_rand(1, $nbActionsMaxPerVisit);
			Piwik_VisitorGenerator_Visit::setTimestampToUse($this->getTimestampToUse());
						
			$this->generateNewVisit();
			for($j = 1; $j <= $nbActions; $j++)
			{
				$this->generateActionVisit();
				$this->saveVisit();
			}
			$nbActionsTotal += $nbActions;
		}
		return $nbActionsTotal;
	}