Пример #1
0
 /**
  * Load metrics from last X days and cache them
  *
  * @param integer $days Number of days you want to load and cache
  *
  * @return EntryInterface[] Array of loaded entries
  */
 public function loadEntriesFromLastDays($days)
 {
     $entries = $this->entryRepository->getEntriesFromLastDays($days);
     foreach ($entries as $entry) {
         $this->metricsBucket->add($entry);
     }
     return $entries;
 }
Пример #2
0
 /**
  * Adds a new entry into database and into metrics bucket.
  *
  * @param string   $token    Event
  * @param string   $event    Token
  * @param string   $uniqueId Unique id
  * @param int      $type     Type
  * @param DateTime $dateTime DateTime
  *
  * @return $this Self Object
  */
 public function addEntry($token, $event, $uniqueId, $type, DateTime $dateTime)
 {
     $entry = $this->entryFactory->create($token, $event, $uniqueId, $type, $dateTime);
     $this->entryObjectManager->persist($entry);
     $this->entryObjectManager->flush($entry);
     $this->metricsBucket->add($entry);
     return $this;
 }