/**
  * Calculate the last date for existing downline snap or the "yesterday" for the first change log entry.
  *
  * @param Request\GetLastDate $request
  *
  * @return Response\GetLastDate
  */
 public function getLastDate(Request\GetLastDate $request)
 {
     $result = new Response\GetLastDate();
     $this->_logger->info("'Get Last Data' operation is requested.");
     /* get the maximal date for existing snapshot */
     $snapMaxDate = $this->_repoSnap->getMaxDatestamp();
     if ($snapMaxDate) {
         /* there is snapshots data */
         $result->setData([Response\GetLastDate::LAST_DATE => $snapMaxDate]);
         $result->markSucceed();
     } else {
         /* there is no snapshot data yet, get change log minimal date  */
         $changelogMinDate = $this->_repoChange->getChangelogMinDate();
         if ($changelogMinDate) {
             $period = $this->_toolPeriod->getPeriodCurrent($changelogMinDate);
             $dayBefore = $this->_toolPeriod->getPeriodPrev($period);
             $this->_logger->info("The last date for downline snapshot is '{$dayBefore}'.");
             $result->setData([Response\GetLastDate::LAST_DATE => $dayBefore]);
             $result->markSucceed();
         }
     }
     $this->_logger->info("'Get Last Data' operation is completed.");
     return $result;
 }