private static function lookup_preview_harvests()
 {
     $mysqli =& $GLOBALS['mysqli_connection'];
     $GLOBALS['hierarchy_preview_harvest_event'] = array();
     $result = $mysqli->query("SELECT r.hierarchy_id, max(he.id) as max FROM resources r JOIN harvest_events he ON (r.id=he.resource_id) GROUP BY r.hierarchy_id");
     while ($result && ($row = $result->fetch_assoc())) {
         $harvest_event = HarvestEvent::find($row['max']);
         if (!$harvest_event->published_at) {
             $GLOBALS['hierarchy_preview_harvest_event'][$row['hierarchy_id']] = $row['max'];
         }
     }
 }
Example #2
0
 public function get_marine_stats()
 {
     if (!$this->worms_latest_harvest_event_id) {
         return false;
     }
     $latest_harvest_event = HarvestEvent::find($this->worms_latest_harvest_event_id);
     $result = $this->mysqli_slave->query("SELECT e.created_at FROM eol_statistics e ORDER BY e.id DESC LIMIT 1");
     if ($result && ($row = $result->fetch_assoc())) {
         $latest_stats = $row['created_at'];
     } else {
         return true;
     }
     $latest_harvest = $latest_harvest_event->published_at;
     $date = new \DateTime($latest_harvest);
     $latest_harvest = $date->format('Y-m-d');
     $date = new \DateTime($latest_stats);
     $latest_stats = $date->format('Y-m-d');
     print "\n\n {$latest_stats} -- {$latest_harvest}";
     if ($latest_harvest >= $latest_stats) {
         return true;
     } else {
         return false;
     }
     // No need to calculate marine stats
 }