Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#655 Created "mark group received" runner #700

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

bjendres
Copy link
Member

@bjendres bjendres commented Mar 12, 2024

This additional runner will avoid timeout issues when marking large SEPA groups as "received".

systopia-reference: 19531

@bjendres bjendres added this to the 1.10 milestone Mar 12, 2024
@bjendres
Copy link
Member Author

@jensschuppe Could you please have a brief look to see you can spot any major blunders?

Copy link
Collaborator

@jensschuppe jensschuppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is old code, so some remarks might be negligible. But if there's time and budget, some refactoring would make sense.

LIMIT %5", [
1 => [$this->txgroup['id'], 'Integer'],
2 => [implode(',', $this->origin_status_ids), 'Integer'],
3 => [$status_inProgress, 'Integer'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placeholder %3 seems obsolete now.

CRM_Utils_System::setTitle(E::ts('Mark SEPA group received'));

// get the group ID
$group_id = (int) $_REQUEST['group_id'] ?? 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use \CRM_Utils_Request::retrieve().

*
*/

require_once 'CRM/Core/Page.php';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary, as the class loader will take care of it.

Comment on lines +41 to +45
$queue = CRM_Queue_Service::singleton()->create([
'type' => 'Sql',
'name' => 'sdd_close',
'reset' => TRUE,
));
]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the docs, this should use the new Civi::queue() syntax.

$queue->createItem(new CRM_Sepa_Logic_Queue_Close('update_contribution', $txgroup, $target_contribution_status, $offset));
}

// finally: render XML and mark the group
$queue->createItem(new CRM_Sepa_Logic_Queue_Close('create_xml', $txgroup, $target_group_status));
if ($is_received_runner) {
$queue->createItem(new CRM_Sepa_Logic_Queue_Close('create_xml', $txgroup, $target_group_status));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the docs, a queue should be filled with CRM_Queue_Task objects when it is supposed to be run using CiviCRM's queue runners. Not sure how much BC there is for the concept being used here, though …

$queue->createItem(new CRM_Sepa_Logic_Queue_Close('update_contribution', $txgroup, $target_contribution_status, $offset));
}

// finally: render XML and mark the group
$queue->createItem(new CRM_Sepa_Logic_Queue_Close('create_xml', $txgroup, $target_group_status));
if ($is_received_runner) {
$queue->createItem(new CRM_Sepa_Logic_Queue_Close('create_xml', $txgroup, $target_group_status));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding items should only be done when the queue is empty or doesn't exist. This should be checked with $queue->existsQueue() before adding items. Otherwise, loading the CRM_Sepa_Page_MarkGroupReceived page again would load the existing queue and add items for all contributions again, and also starting the runner again (which might stall either runner due to the next item being already claimed by the other).

@bjendres bjendres mentioned this pull request Mar 22, 2024
4 tasks
@bjendres
Copy link
Member Author

I know this is old code, so some remarks might be negligible. But if there's time and budget, some refactoring would make sense.

I agree, but the version as-is has been tested by 3 clients now, and I'm going to merge it the way it is. I created #703 for your suggestions.

@bjendres bjendres merged commit f42aefe into master Mar 22, 2024
0 of 2 checks passed
@jensschuppe jensschuppe deleted the issue/655-mark-received-runner branch August 19, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants