public function loadPage()
 {
     $story_table = new PhabricatorFeedStoryData();
     $conn = $story_table->establishConnection('r');
     $data = queryfx_all($conn, 'SELECT story.* FROM %T story %Q %Q %Q %Q %Q', $story_table->getTableName(), $this->buildJoinClause($conn), $this->buildWhereClause($conn), $this->buildGroupClause($conn), $this->buildOrderClause($conn), $this->buildLimitClause($conn));
     $results = PhabricatorFeedStory::loadAllFromRows($data);
     return $this->processResults($results);
 }
 protected function loadPage()
 {
     $story_table = new PhabricatorFeedStoryData();
     $notification_table = new PhabricatorFeedStoryNotification();
     $conn = $story_table->establishConnection('r');
     $data = queryfx_all($conn, 'SELECT story.*, notif.hasViewed FROM %T notif
      JOIN %T story ON notif.chronologicalKey = story.chronologicalKey
      %Q
      ORDER BY notif.chronologicalKey DESC
      %Q', $notification_table->getTableName(), $story_table->getTableName(), $this->buildWhereClause($conn), $this->buildLimitClause($conn));
     $viewed_map = ipull($data, 'hasViewed', 'chronologicalKey');
     $stories = PhabricatorFeedStory::loadAllFromRows($data, $this->getViewer());
     foreach ($stories as $key => $story) {
         $story->setHasViewed($viewed_map[$key]);
     }
     return $stories;
 }
 public function execute()
 {
     if (!$this->userPHID) {
         throw new Exception("Call setUser() before executing the query");
     }
     $story_table = new PhabricatorFeedStoryData();
     $notification_table = new PhabricatorFeedStoryNotification();
     $conn = $story_table->establishConnection('r');
     $data = queryfx_all($conn, "SELECT story.*, notif.primaryObjectPHID, notif.hasViewed FROM %T notif\n         JOIN %T story ON notif.chronologicalKey = story.chronologicalKey\n         %Q\n         ORDER BY notif.chronologicalKey DESC\n         %Q", $notification_table->getTableName(), $story_table->getTableName(), $this->buildWhereClause($conn), $this->buildLimitClause($conn));
     $viewed_map = ipull($data, 'hasViewed', 'chronologicalKey');
     $primary_map = ipull($data, 'primaryObjectPHID', 'chronologicalKey');
     $stories = PhabricatorFeedStory::loadAllFromRows($data);
     foreach ($stories as $key => $story) {
         $story->setHasViewed($viewed_map[$key]);
         $story->setPrimaryObjectPHID($primary_map[$key]);
     }
     return $stories;
 }
 protected function willFilterPage(array $data)
 {
     return PhabricatorFeedStory::loadAllFromRows($data, $this->getViewer());
 }