Ejemplo n.º 1
0
 /**
  * Load latest log entry.
  */
 public function loadLatestLogEntries($jobs, $log_types)
 {
     if (Database::getConnection()->databaseType() !== 'mysql') {
         return parent::loadLatestLogEntries($jobs, $log_types);
     }
     $result = db_query("SELECT l.*\n    FROM {ultimate_cron_log} l\n    JOIN (\n      SELECT l3.name, (\n        SELECT l4.lid\n        FROM {ultimate_cron_log} l4\n        WHERE l4.name = l3.name\n        AND l4.log_type IN (:log_types)\n        ORDER BY l4.name desc, l4.start_time DESC\n        LIMIT 1\n      ) AS lid FROM {ultimate_cron_log} l3\n      GROUP BY l3.name\n    ) l2 on l2.lid = l.lid", array(':log_types' => $log_types));
     $log_entries = array();
     while ($object = $result->fetchObject()) {
         if (isset($jobs[$object->name])) {
             $log_entries[$object->name] = new $this->log_entry_class($object->name, $this);
             $log_entries[$object->name]->setData((array) $object);
         }
     }
     foreach ($jobs as $name => $job) {
         if (!isset($log_entries[$name])) {
             $log_entries[$name] = new $this->log_entry_class($name, $this);
         }
     }
     return $log_entries;
 }
Ejemplo n.º 2
0
 /**
  * Load latest log entry.
  */
 public function loadLatestLogEntries($jobs, $log_types)
 {
     if (Database::getConnection()->databaseType() !== 'mysql') {
         return parent::loadLatestLogEntries($jobs, $log_types);
     }
     $subquery = db_select('ultimate_cron_log', 'l3')->fields('l3', array('name', 'log_type'))->groupBy('name')->groupBy('log_type');
     $subquery->addExpression('MAX(l3.start_time)', 'start_time');
     $query = db_select('ultimate_cron_log', 'l1')->fields('l1');
     $query->join($subquery, 'l2', 'l1.name = l2.name AND l1.start_time = l2.start_time AND l1.log_type = l2.log_type');
     $query->condition('l2.log_type', $log_types, 'IN');
     $result = $query->execute();
     $log_entries = array();
     while ($object = $result->fetchObject()) {
         if (isset($jobs[$object->name])) {
             $log_entries[$object->name] = new $this->log_entry_class($object->name, $this);
             $log_entries[$object->name]->setData((array) $object);
         }
     }
     foreach ($jobs as $name => $job) {
         if (!isset($log_entries[$name])) {
             $log_entries[$name] = new $this->log_entry_class($name, $this);
         }
     }
     return $log_entries;
 }