-
Notifications
You must be signed in to change notification settings - Fork 809
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
CRM: Mailpoet Sync issue with the sync percentage calculation #37508
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. |
// check for completion | ||
$total_page_count = $this->get_total_page_count(); | ||
if ( $page_no >= $total_page_count ) { | ||
if ( $page_no >= ( $total_page_count - 1 ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$page_no
works in the 0..(total_pages - 1)
range and $total_page_count
in the 1..total_pages
range.
// set pointer to last page | ||
$this->set_resume_from_page( $total_page_count ); | ||
// set pointer to last processed page | ||
$this->set_resume_from_page( $page_no ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to set the latest processed page here, not the total, that is total_pages - 1
or $page_no
$this->debug( 'Pages completed: ' . $this->current_page . ' / ' . $this->mailpoet_total_pages ); | ||
$this->debug( 'Subscribers completed: ' . min( $this->current_page * $this->subscribers_per_page, $this->mailpoet_total_subscribers ) . ' / ' . $this->mailpoet_total_subscribers ); | ||
$this->debug( 'Percentage completed: ' . $percentage_completed . '%' ); | ||
$this->debug( 'Pages completed: ' . ( $this->current_page + 1 ) . ' / ' . $this->mailpoet_total_pages ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to match ranges, so the current page should be increased +1 for this debug info.
$total_pages = (int)$percentage_counts['total_pages']; | ||
$total_remaining_pages = $percentage_counts['total_pages'] - $percentage_counts['page_no']; | ||
|
||
$total_remaining_pages = $percentage_counts['total_pages'] - ( $percentage_counts['page_no'] + 1 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to match the same page range, so we have to increase the page_no
+1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my previous comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves https://github.com/Automattic/zero-bs-crm/issues/3223
Resolves https://github.com/Automattic/zero-bs-crm/issues/3462
Proposed changes:
This PR resolved the issue we had with the MailPoet Sync, calculating the complete percentage of the job. The sync process works well, the issue was about calculating the total percentage of the work. Specificaly it was about how the calculation code was handling the pagination, the current page goes from
0
to(total_page - 1)
, and the calculation code was interpreting the current page as1
tototal_page
range, so that was the reason because it seems stuck in the latest page.Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
/wp-admin/admin.php?page=mailpoet-import#/step_method_selection
and select thePaste the data into a text box
method. With the help of ChatGPT create a list of 126 subscribers:I copied and pated it for you here: 348ba-pb
The debug output data should match with the expected. If you get 66% re-load the page, and it will complete it. MailPoet Sync runs one page per sync job, so you have to refresh it.