/**
  * @return Collection
  */
 public function getQueueCollection()
 {
     // Initialize the queue collection
     if ($this->summaryData == null) {
         /** @var $queueCollection \ClassyLlama\AvaTax\Model\ResourceModel\Queue\Collection */
         $this->queueCollection = $this->queueCollectionFactory->create();
     }
     return $this->queueCollection;
 }
 /**
  * Load the queue stats
  */
 public function getQueueFailureStats()
 {
     // check to see if we've already loaded the queue stats
     if ($this->queueFailureStats === null) {
         $queueCollection = $this->queueCollectionFactory->create();
         // get the stats from the collection
         $this->queueFailureStats = $queueCollection->getQueueFailureStats();
         $this->queueFailureCount = array_sum($this->queueFailureStats);
     }
     return $this->queueFailureStats;
 }
 /**
  * Load the queue stats
  */
 public function loadQueueStats()
 {
     // check to see if we've already loaded the queue stats
     if ($this->statQueueCount === null) {
         $queueCollection = $this->queueCollectionFactory->create();
         // get the stats from the collection
         $queueStats = $queueCollection->getQueuePendingMoreThanADay();
         // load the object properties with the stats
         $this->statQueueCount = $queueStats[$queueCollection::SUMMARY_COUNT_FIELD_NAME];
         $this->statQueueLastCreatedAt = $queueStats[$queueCollection::SUMMARY_LAST_CREATED_AT_FIELD_NAME];
         $this->statQueueLastUpdatedAt = $queueStats[$queueCollection::SUMMARY_LAST_UPDATED_AT_FIELD_NAME];
     }
 }
Example #4
0
 /**
  * Clear the queue of failed records based on config lifetime
  */
 protected function clearFailedQueue()
 {
     // Initialize the queue collection
     /** @var $queueCollection \ClassyLlama\AvaTax\Model\ResourceModel\Queue\Collection */
     $queueCollection = $this->queueCollectionFactory->create();
     $queueCollection->addQueueStatusFilter(Queue::QUEUE_STATUS_FAILED);
     // Get configuration for record lifetime
     $completeDays = $this->avaTaxConfig->getQueueFailedLifetime();
     // Calculate the number of seconds to adjust the filter
     // 86400 seconds == 60 seconds * 60 minutes * 24 hours == 1 day
     $secondsBeforeNow = $completeDays * 60 * 60 * 24;
     // Add filters
     $queueCollection->addCreatedAtBeforeFilter($secondsBeforeNow);
     $queueCollection->addUpdatedAtBeforeFilter($secondsBeforeNow);
     // Process each queued entity
     /** @var $queue Queue */
     foreach ($queueCollection as $queue) {
         // Remove the queue record
         $queue->delete();
         $this->deleteFailedCount++;
     }
 }