Sbisson has uploaded a new change for review.

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

Change subject: Maintenance script sends notifications immediately
......................................................................

Maintenance script sends notifications immediately

Update the "processEchoEmailBatch" to allow sending all
notifications immediately even if configured to be
daily or weekly.

Change-Id: I6ebeea86708247700d1950e0f6471c7b3d1fecd2
---
M includes/EmailBatch.php
M maintenance/processEchoEmailBatch.php
2 files changed, 10 insertions(+), 3 deletions(-)


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

diff --git a/includes/EmailBatch.php b/includes/EmailBatch.php
index 8e84798..f6d3ca1 100644
--- a/includes/EmailBatch.php
+++ b/includes/EmailBatch.php
@@ -37,7 +37,7 @@
         * @param $userId int
         * @return MWEchoEmailBatch/false
         */
-       public static function newFromUserId( $userId ) {
+       public static function newFromUserId( $userId, $enforceFrequency = true 
) {
                $batchClassName = self::getEmailBatchClass();
 
                $user = User::newFromId( intval( $userId ) );
@@ -71,7 +71,7 @@
                if ( $userLastBatch ) {
                        // use 20 as hours per day to get estimate
                        $nextBatch = wfTimestamp( TS_UNIX, $userLastBatch ) + 
$userEmailSetting * 20 * 60 * 60;
-                       if ( wfTimestamp( TS_MW, $nextBatch ) > 
wfTimestampNow() ) {
+                       if ( $enforceFrequency && wfTimestamp( TS_MW, 
$nextBatch ) > wfTimestampNow() ) {
                                return false;
                        }
                }
diff --git a/maintenance/processEchoEmailBatch.php 
b/maintenance/processEchoEmailBatch.php
index 222af2d..9a628c5 100644
--- a/maintenance/processEchoEmailBatch.php
+++ b/maintenance/processEchoEmailBatch.php
@@ -20,10 +20,17 @@
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Process email digest";
+
+               $this->addOption(
+                       "ignoreConfiguredSchedule",
+                       "Send all pending notifications immediately even if 
configured to be weekly or daily.",
+                       false, false, "i" );
        }
 
        public function execute() {
                global $wgEchoCluster;
+
+               $ignoreConfiguredSchedule = $this->getOption( 
"ignoreConfiguredSchedule", 0 );
 
                $this->output( "Started processing... \n" );
 
@@ -39,7 +46,7 @@
                        foreach ( $res as $row ) {
                                $userId = intval( $row->eeb_user_id );
                                if ( $userId && $userId > $startUserId ) {
-                                       $emailBatch = 
MWEchoEmailBatch::newFromUserId( $userId );
+                                       $emailBatch = 
MWEchoEmailBatch::newFromUserId( $userId, !$ignoreConfiguredSchedule );
                                        if ( $emailBatch ) {
                                                $this->output( "processing 
user_Id " . $userId . " \n" );
                                                $emailBatch->process();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ebeea86708247700d1950e0f6471c7b3d1fecd2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Sbisson <sbis...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to