Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/79086
Change subject: Allow filtering of notification types
......................................................................
Allow filtering of notification types
This allows the mobile site to count how many users are being
thanked
Change-Id: I72758151bf2e934dd1f92c5c19bf9c2a9784da0e
---
M includes/DbEchoBackend.php
1 file changed, 11 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/86/79086/1
diff --git a/includes/DbEchoBackend.php b/includes/DbEchoBackend.php
index 4f5eeff..84a6afa 100644
--- a/includes/DbEchoBackend.php
+++ b/includes/DbEchoBackend.php
@@ -265,14 +265,13 @@
* @param $dbSource string use master or slave storage to pull count
* @return int
*/
- public function getNotificationCount( $user, $dbSource ) {
+ public function getNotificationCount( $user, $dbSource, $eventType=Null
) {
// double check
if ( !in_array( $dbSource, array( DB_SLAVE, DB_MASTER ) ) ) {
$dbSource = DB_SLAVE;
}
$eventTypesToLoad =
EchoNotificationController::getUserEnabledEvents( $user, 'web' );
-
if ( !$eventTypesToLoad ) {
return 0;
}
@@ -280,21 +279,25 @@
global $wgEchoMaxNotificationCount;
$db = MWEchoDbFactory::getDB( $dbSource );
+ $where = array(
+ 'notification_user' => $user->getId(),
+ 'notification_bundle_base' => 1,
+ 'notification_read_timestamp' => null,
+ 'event_type' => $eventTypesToLoad,
+ );
$res = $db->select(
array( 'echo_notification', 'echo_event' ),
array( 'notification_event' ),
- array(
- 'notification_user' => $user->getId(),
- 'notification_bundle_base' => 1,
- 'notification_read_timestamp' => null,
- 'event_type' => $eventTypesToLoad,
- ),
+ $where,
__METHOD__,
array( 'LIMIT' => $wgEchoMaxNotificationCount + 1 ),
array(
'echo_event' => array( 'LEFT JOIN',
'notification_event=event_id' ),
)
);
+ if ( $eventType ) {
+ $where['notification_event'] = $eventType;
+ }
return $db->numRows( $res );
}
--
To view, visit https://gerrit.wikimedia.org/r/79086
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I72758151bf2e934dd1f92c5c19bf9c2a9784da0e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits