jenkins-bot has submitted this change and it was merged.
Change subject: I-2. Change the default number of Flow Messages in the flyout
......................................................................
I-2. Change the default number of Flow Messages in the flyout
Previously this was loading 25 unread notifications. If less than 25 were
found it would add in 3 read notifications so it wasn't empty.
This patch changes things around to always return 25 notifications if the
user has at least that many. Instead of backfilling a static count of 3
we backfill 25 - $count with previously read notifications.
Change-Id: I723316486216d7b9dacfcc9765c1a8212e973518
---
M api/ApiEchoNotifications.php
M includes/mapper/NotificationMapper.php
2 files changed, 22 insertions(+), 17 deletions(-)
Approvals:
Matthias Mullie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/api/ApiEchoNotifications.php b/api/ApiEchoNotifications.php
index 4cad169..8f6e9c8 100644
--- a/api/ApiEchoNotifications.php
+++ b/api/ApiEchoNotifications.php
@@ -124,8 +124,7 @@
$notifMapper = new EchoNotificationMapper();
- // Unread notifications + possbile 3 read notification
depending on result number
- // We don't care about next offset in this case
+ // Prefer unread notifications. We don't care about next offset
in this case
if ( $unreadFirst ) {
wfProfileIn( __METHOD__ . '-fetch-data-unread-first' );
$notifs = $notifMapper->fetchUnreadByUser( $user,
$limit, $eventTypes );
@@ -133,17 +132,17 @@
// 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;
- }
+ $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: merged
Gerrit-Change-Id: I723316486216d7b9dacfcc9765c1a8212e973518
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits