Skip to content

Commit

Permalink
GP-44423 Display background execution status in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mflandorfer committed Jan 23, 2024
1 parent f9db213 commit d728c1b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
9 changes: 5 additions & 4 deletions CRM/Sepa/Logic/Queue/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ public static function launchUpdateRunner($mode) {

// Create a queue
$queue_sequential = Civi::queue('sdd_update_sequential', [
'error' => 'abort',
'reset' => TRUE,
'runner' => 'task',
'type' => 'Sql',
'error' => 'abort',
'lease_time' => 60 * 60 * 24, // 24 hours
'reset' => TRUE,
'runner' => 'task',
'type' => 'Sql',
]);

// Check whether background queues are enabled
Expand Down
17 changes: 15 additions & 2 deletions CRM/Sepa/Page/DashBoard.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ class CRM_Sepa_Page_DashBoard extends CRM_Core_Page {

function run() {
CRM_Utils_System::setTitle(ts('CiviSEPA Dashboard', array('domain' => 'org.project60.sepa')));
// get requested group status

// Check current batching status
$batching_lock_setting = Civi::settings()->get('sdd_async_batching_lock');
$batching_in_progress = (bool) ($batching_lock_setting['sdd_async_update_lock'] ?? 0);
$this->assign('batching_in_progress', $batching_in_progress);

// Get requested group status
if (isset($_REQUEST['status'])) {
if ($_REQUEST['status'] != 'open' && $_REQUEST['status'] != 'closed') {
$status = 'open';
Expand Down Expand Up @@ -145,7 +151,14 @@ function callBatcher($mode) {
if ($async_batching) {
// use the runner rather that the API (this doesn't return)
CRM_Sepa_Logic_Queue_Update::launchUpdateRunner($mode);
CRM_Utils_System::civiExit();

CRM_Core_Session::setStatus(ts(
"Tasks for updating SEPA %1 mandates have been added to a queue for background execution",
[ 1 => $mode, 'domain' => 'org.project60.sepa' ],
'info'
));

CRM_Utils_System::redirect('/civicrm/sepa/dashboard');
}

if ($mode=="OOFF") {
Expand Down
6 changes: 6 additions & 0 deletions templates/CRM/Sepa/Page/DashBoard.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
| written permission from the original author(s). |
+-------------------------------------------------------*}

{if $batching_in_progress}
<div class="status">
{ts domain="org.project60.sepa"}Update of SEPA mandates in progress{/ts}
</div>
{/if}

<div class="crm-actions-ribbon">
<ul id="actions">
{if $status eq 'closed'}
Expand Down

0 comments on commit d728c1b

Please sign in to comment.