jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/354511 )

Change subject: Create time limit based on user configuration Bug: T163412
......................................................................


Create time limit based on user configuration
Bug: T163412

Change-Id: I475881c52ad5c720a985bf4b0bb2822496ecf54e
---
M sites/all/modules/thank_you/thank_you.module
1 file changed, 14 insertions(+), 1 deletion(-)

Approvals:
  jenkins-bot: Verified
  Ejegg: Looks good to me, approved



diff --git a/sites/all/modules/thank_you/thank_you.module 
b/sites/all/modules/thank_you/thank_you.module
index 31b7c32..75174f5 100644
--- a/sites/all/modules/thank_you/thank_you.module
+++ b/sites/all/modules/thank_you/thank_you.module
@@ -661,6 +661,13 @@
                        700 => 700,
                ),
        );
+  $form['thank_you_batch_time'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Job time limit (in seconds)'),
+    '#description' => t('Maximum elapsed duration of a thank you job, after 
which we will abort from the loop.  This can be used to set a reliable duty 
cycle for the job.  A time limit is required.'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('thank_you_batch_time', 90),
+  );
 
        // this is still in use
   $form['thank_you_onestep_unsubscribe'] = array(
@@ -705,6 +712,8 @@
 function thank_you_batch_process(){
        civicrm_initialize();
        // the following variables should be set in the module settings, not 
here
+       $startTime = time();
+       $timeLimit = variable_get('thank_you_batch_time', 90); 
        $days = variable_get( 'thank_you_days', false );
        $batch = variable_get( 'thank_you_batch', false );
        $enabled = variable_get( 'thank_you_enabled', 'true' );
@@ -754,8 +763,12 @@
        $consecutiveFailures = 0;
        $failureThreshold = variable_get( 'thank_you_failure_threshold', 5 );
        $abort = false;
-
+       $endTime = $startTime + $timeLimit;
        foreach( $result as $contribution ) {
+               if (time() >= $endTime){
+                       watchdog("Batch time limit elapsed", WATCHDOG_NOTICE);
+                       break;
+               }
                watchdog(
                        "thank_you",
                        "Attempting to send thank you mail for contribution ID 
[{$contribution->id}], trxn_id [{$contribution->trxn_id}]",

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I475881c52ad5c720a985bf4b0bb2822496ecf54e
Gerrit-PatchSet: 8
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Mepps <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Mepps <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to