EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/162180

Change subject: I-2. Change the default number of Flow Messages in the flyout, 
from 3 to 25
......................................................................

I-2. Change the default number of Flow Messages in the flyout, from 3 to 25

Change-Id: I723316486216d7b9dacfcc9765c1a8212e973518
---
M api/ApiEchoNotifications.php
M includes/mapper/NotificationMapper.php
2 files changed, 24 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/80/162180/1

diff --git a/api/ApiEchoNotifications.php b/api/ApiEchoNotifications.php
index 4cad169..08bf847 100644
--- a/api/ApiEchoNotifications.php
+++ b/api/ApiEchoNotifications.php
@@ -133,17 +133,21 @@
                        // then fill the result with some read notifications
                        $count = count( $notifs );
                        if ( $count < $limit ) {
-                               // We could add another function for 
"notification_read_timestamp is not null"
-                               // but it's probably not good to add negation 
condition to a query
-                               $mixedNotifs = $notifMapper->fetchByUser( 
$user, $count + 3, null, $eventTypes );
+                               // Query planner should be smart enough that 
passing a short list of ids to exclude
+                               // will only visit at most that number of extra 
rows.
+                               $mixedNotifs = $notifMapper->fetchByUser(
+                                       $user,
+                                       $limit - $count,
+                                       null,
+                                       $eventTypes,
+                                       array_keys( $notifs )
+                               );
                                foreach ( $mixedNotifs as $notif ) {
-                                       if ( !isset( 
$notifs[$notif->getEvent()->getId()] ) ) {
-                                               if ( $count >= $limit ) {
-                                                       break;
-                                               }
-                                               $count++;
-                                               
$notifs[$notif->getEvent()->getId()] = $notif;
+                                       if ( $count >= $limit ) {
+                                               break;
                                        }
+                                       $count++;
+                                       $notifs[$notif->getEvent()->getId()] = 
$notif;
                                }
                        }
                        wfProfileOut( __METHOD__ . '-fetch-data-unread-first' );
diff --git a/includes/mapper/NotificationMapper.php 
b/includes/mapper/NotificationMapper.php
index 52aca10..9545c8d 100644
--- a/includes/mapper/NotificationMapper.php
+++ b/includes/mapper/NotificationMapper.php
@@ -116,13 +116,15 @@
 
        /**
         * Get Notification by user in batch along with limit, offset etc
-        * @param User the user to get notifications for
-        * @param int The maximum number of notifications to return
-        * @param string Used for offset
-        * @param array Event types to load
+        *
+        * @param User $user the user to get notifications for
+        * @param int $limit The maximum number of notifications to return
+        * @param string $continue Used for offset
+        * @param array $eventTypes Event types to load
+        * @param array $excludeEventIds Event id's to exclude.
         * @return EchoNotification[]
         */
-       public function fetchByUser( User $user, $limit, $continue, array 
$eventTypes = array() ) {
+       public function fetchByUser( User $user, $limit, $continue, array 
$eventTypes = array(), array $excludeEventIds = array() ) {
                $dbr = $this->dbFactory->getEchoDb( DB_SLAVE );
 
                if ( !$eventTypes ) {
@@ -143,6 +145,10 @@
                        'notification_bundle_base' => 1
                );
 
+               if ( $excludeEventIds ) {
+                       $conds[] = 'event_id NOT IN ( ' . $dbr->makeList( 
$excludeEventIds ) . ' ) ';
+               }
+
                $offset = $this->extractQueryOffset( $continue );
 
                // Start points are specified

-- 
To view, visit https://gerrit.wikimedia.org/r/162180
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I723316486216d7b9dacfcc9765c1a8212e973518
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to