Example #1
0
 public static function aggregate_logs_per_hour($start)
 {
     $end = $start + 3600;
     $ds_request = Ds::connect(ds_requests);
     $ds_stat = Ds::connect(ds_stat_counters);
     $doc_id = $start . '-' . $end;
     $hour_doc = array('browser' => array(), 'country' => array(), 'total' => 0, 'urls' => array());
     $requests = $ds_request->find(array('$and' => array(array('tson' => array('$gte' => $start)), array('tson' => array('$lt' => $end)))));
     $hour_doc_prepped = Statistics::get_hour_doc_prepared($requests);
     $storable = array_merge($hour_doc, $hour_doc_prepped);
     try {
         $ds_stat->update(array('_id' => $doc_id), array('$set' => $storable), array('w' => 1, 'upsert' => true));
     } catch (Exception $e) {
     }
 }
Example #2
0
 /**
  * mail was sent
  */
 private static function mailerCompleted($id, $state = true)
 {
     $mail_queue_collection = Ds::connect(ds_mail_queue);
     $err = null;
     if ($state !== true) {
         $err = (string) $state;
     }
     $mail_queue_collection->update(array('_id' => $id), array('$set' => array('cts' => time(), 'err' => $err)));
     return true;
 }