/**
  * Set start time and end time based on current process data
  *
  * @param Mage_Index_Model_Process $process
  * @return $this
  */
 public function setDataFromProcess(Mage_Index_Model_Process $process)
 {
     $startTime = new DateTime($process->getStartedAt());
     $endTime = new DateTime($process->getEndedAt());
     $runningTime = $endTime->getTimestamp() - $startTime->getTimestamp();
     $this->setData(array('process_id' => $process->getId(), 'started_at' => $process->getStartedAt(), 'ended_at' => $process->getEndedAt(), 'running_time' => $runningTime));
     return $this;
 }
 public function getProgress(Mage_Index_Model_Process $process)
 {
     $avgTime = Mage::getModel('hackathon_indexerstats_resource/history')->getAvg($process->getId());
     $currentTime = new DateTime();
     $startTime = new DateTime($process->getStartedAt());
     $estimatedEndTime = new DateTime($process->getStartedAt());
     $estimatedEndTime->add(new DateInterval('PT' . $avgTime . 'S'));
     $processDiff = $currentTime->getTimestamp() - $startTime->getTimestamp();
     if ($avgTime == 0) {
         return 1;
     }
     return $processDiff / $avgTime;
 }