Changeset View
Changeset View
Standalone View
Standalone View
src/applications/notification/query/PhabricatorNotificationQuery.php
| Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | /* -( Query Execution )---------------------------------------------------- */ | ||||
| protected function loadPage() { | protected function loadPage() { | ||||
| $story_table = new PhabricatorFeedStoryData(); | $story_table = new PhabricatorFeedStoryData(); | ||||
| $notification_table = new PhabricatorFeedStoryNotification(); | $notification_table = new PhabricatorFeedStoryNotification(); | ||||
| $conn = $story_table->establishConnection('r'); | $conn = $story_table->establishConnection('r'); | ||||
| $data = queryfx_all( | $data = queryfx_all( | ||||
| $conn, | $conn, | ||||
| 'SELECT story.*, notif.hasViewed FROM %T notif | 'SELECT story.*, notif.hasViewed FROM %R notif | ||||
| JOIN %T story ON notif.chronologicalKey = story.chronologicalKey | JOIN %R story ON notif.chronologicalKey = story.chronologicalKey | ||||
| %Q | %Q | ||||
| ORDER BY notif.chronologicalKey DESC | ORDER BY notif.chronologicalKey DESC | ||||
| %Q', | %Q', | ||||
| $notification_table->getTableName(), | $notification_table, | ||||
| $story_table->getTableName(), | $story_table, | ||||
| $this->buildWhereClause($conn), | $this->buildWhereClause($conn), | ||||
| $this->buildLimitClause($conn)); | $this->buildLimitClause($conn)); | ||||
| $viewed_map = ipull($data, 'hasViewed', 'chronologicalKey'); | $viewed_map = ipull($data, 'hasViewed', 'chronologicalKey'); | ||||
| $stories = PhabricatorFeedStory::loadAllFromRows( | $stories = PhabricatorFeedStory::loadAllFromRows( | ||||
| $data, | $data, | ||||
| $this->getViewer()); | $this->getViewer()); | ||||
| Show All 17 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
| if ($this->unread !== null) { | if ($this->unread !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'notif.hasViewed = %d', | 'notif.hasViewed = %d', | ||||
| (int)!$this->unread); | (int)!$this->unread); | ||||
| } | } | ||||
| if ($this->keys) { | if ($this->keys !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'notif.chronologicalKey IN (%Ls)', | 'notif.chronologicalKey IN (%Ls)', | ||||
| $this->keys); | $this->keys); | ||||
| } | } | ||||
| return $where; | return $where; | ||||
| } | } | ||||
| protected function willFilterPage(array $stories) { | |||||
| foreach ($stories as $key => $story) { | |||||
| if (!$story->isVisibleInNotifications()) { | |||||
| unset($stories[$key]); | |||||
| } | |||||
| } | |||||
| return $stories; | |||||
| } | |||||
| protected function getResultCursor($item) { | protected function getResultCursor($item) { | ||||
| return $item->getChronologicalKey(); | return $item->getChronologicalKey(); | ||||
| } | } | ||||
| public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
| return 'PhabricatorNotificationsApplication'; | return 'PhabricatorNotificationsApplication'; | ||||
| } | } | ||||
| } | } | ||||