You are here

public function HeartbeatStream::parseMessages in Heartbeat 7

Create the well-formed activity messages from a result. HeartbeatParser will do most of the work here.

2 calls to HeartbeatStream::parseMessages()
HeartbeatStream::execute in includes/heartbeatstream.inc
Function that reorganizes a query result of messages into a stream of heartbeat activity objects.
HeartbeatStream::executeViews in includes/heartbeatstream.inc
executeViews().

File

includes/heartbeatstream.inc, line 800
HeartbeatStream object is the object that takes stream configuration to create a stream of activity objects. It is the controlling organ at the pre-query, query and post-query phases.

Class

HeartbeatStream
Abstract class HeartbeatStream This base class has final template methods which are used by the derived concretes. The HeartbeatStream is a state object that is given to the HeartbeatStreamBuilder to set the access to the current request.

Code

public function parseMessages($result) {
  $heartbeatparser = new HeartbeatParser();
  $heartbeatparser
    ->set_timespan_gap($this->config->grouping_seconds);
  $heartbeatparser
    ->build_sets($result);
  $heartbeatparser
    ->merge_sets();
  $messages = $heartbeatparser
    ->get_messages();

  // $messages = $heartbeatparser->remove_broken_messages();
  $num_total_messages = count($messages);

  // From here we know the number of messages actualy loaded (and allowed)
  $messages = array_slice($messages, 0, $this->messages_max);
  $i = 0;
  foreach ($messages as $key => $message) {
    $message->index = $i;
    $i++;
  }

  // Set the possibility of a pager appearence
  if ($num_total_messages > $this->messages_max) {
    $this->canPage = TRUE;
  }
  return $messages;
}