Example #1
0
 /**
  * Launches the process and generates an exact number of nbVisits
  * 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($nbVisits, $nbActionsMaxPerVisit)
 {
     $nbActionsTotal = 0;
     for ($i = 0; $i < $nbVisits; $i++) {
         $nbActions = mt_rand(1, $nbActionsMaxPerVisit);
         Piwik_LogStats_Generator_Visit::setTimestampToUse($this->getTimestampToUse());
         $this->generateNewVisit();
         for ($j = 1; $j <= $nbActions; $j++) {
             $this->generateActionVisit();
             $this->saveVisit();
         }
         $nbActionsTotal += $nbActions;
     }
     return $nbActionsTotal;
 }
Example #2
0
 protected function getCurrentTimestamp()
 {
     self::$timestampToUse = max(@$this->visitorInfo['visit_last_action_time'], self::$timestampToUse);
     self::$timestampToUse += mt_rand(4, 1840);
     return self::$timestampToUse;
 }