-
-
Notifications
You must be signed in to change notification settings - Fork 817
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-21279: Rebuild recipient list and calculate count on demand, store result in cache #11091
Conversation
2bd4a6e
to
d1090fc
Compare
This looks good. I implemented the PR and everything worked as expected (though I didn't yet monitor the API calls to confirm the reduced number of calls). The one thing I think we should tweak is terminology in the count block. "No recipients" as a default is misleading. Really, the recipient count just hasn't been generated. And I think the circular icon and "refresh" terminology makes sense if you build the count, then add new groups and want to rebuild the count -- but not if you're building it for the first time. What if we had a button that said: "Estimate recipient count" followed by the number, where the default is "(unknown)". If we wanted to distinguish between the original count attempt and subsequent ones, we could have the button text change to "Refresh recipient count" after the original count is built. And we don't need the text "recipients" as part of the count link. I'm concerned, in particular, for existing users who are used to seeing the counts auto-generated. I think we want to be more explicit about the fact that an action needs to be taken. |
I agree with Brian here, I haven't tested this but my instinct is that we need to handle that conversion from the autogenerated to the manual refresh. I like Brian's choice of button text. I was also wondering about whether or not we wanted to have an auto run when we removed groups. The reason is i think people may get confused thinking they are still sending to a higher number but hmm. |
I'd vote against any auto-run -- that's largely the goal of this PR -- to reduce how many times the rebuildRecipients function is hit (as it's potentially a big query, depending on how many groups are included and if any are complex smart groups). Everything should be on-demand. But if we change the button text to "refresh" after the initial build, I think that may be sufficient to alert people to the potential outdatedness of the count. Or... |
@lcdservices @seamuslee001 thanks for your feedback :). Actually now the result is stored in cache so in spite of repeated auto call to
I agree with your suggestions and to derive a conclusive change to recipient text, following need to be done:
|
I'm happy with the points as Brian and Monish have put. As long as there is a visual cue that the recipient count is no longer "valid" per se then i think it will fine. |
@seamuslee001 @lcdservices I have updated the PR. As per the latest change: Wasn't able to show initial text 'Estimate recipient count: (unknown)' on page load, as I didn't found any technique to track the initial page load :( |
@totten @seamuslee001 I need your help in how to present recipient text as:
Is there any way to tell when a page is initially loaded? which I can use here in IF condition. |
Personally, I'd rather the estimate/refresh action be displayed as a button rather than a link. Visually, we want to make sure the user understands clearly that an action must be taken in order to build or refresh the count. And the action behavior should be swapped -- currently if you click the text "estimate/refresh count" it opens the popup with the list of recipients, and if you click the count it refreshes the count. I think the "estimate/refresh count" should be styled as a button and should be what actually regenerates the count. Once a count exists, clicking the count number should open the popup list. |
bd34f6c
to
565f033
Compare
Sorry, I'm a bit late to the party here. But it seems a shame to lose the 'automatic' refresh of the recipient count. I appreciate that we want to reduce load on the server, but is there a better way of doing that than forcing a manual update? Can we...
(I'm not sure how many of these are already in place). I think it's a shame to have to sacrifice usability for a 'technical' issue. I know this is something that our communications team feel quite strongly about too! |
@monishdeb just ran through a test and it looks great I honestly don't think it's a step back in terms of usability. I just applied the PR to my test site and even though it does require a click to generate the estimate, it "feels" like a pretty normal and intuitive experience. Also, there's caching in place, so if you're building a mailing, save and continue, then return to the mailing later, the cached estimate loads immediately. I suggest you apply the PR and test it. |
@lcdservices I will apply the patch tomorrow and test it, and run it past our communications team. Looking at the screencap I think there is still room for improvement, if this is the approach we want to take. For example, it looks like the text colour changes from green to red when the estimate is potentially no longer valid? This raises accessibility (using colour alone to indicate something) and usability (why did that just change colour?) concerns. I'd be happy to do a full test of this tomorrow, running it past our comms team too, and I'll provide a review here. Edit: There are concepts here (like caching the recipient count/list!) that I fully support [= |
Can we try leaving in the auto-calculation, but:
Going further:
I appreciate the current solution has improved a lot but, having spoken to the comms team as well, we do still have some reservations:
|
@JKingsnorth thanks for your feedback :) Let me cover all your concern pointwise:
This is not occurring due to the changes I made, it's because the crmMailing controller is called twice, tried to fix it earlier but didn't get any success.
Yup agree on 3sec lag, need to consult with @totten if there's any side effect. Will change the text during rebuild to 'Estimating...'
And I am going to create a separate JIRA for that. The fix will involve
What if instead of removing the count we replace it will bold red text
How about enabling/disabling the entire cache and rebuild feature under a new CiviMail setting |
Thanks for the comprehensive response @monishdeb It all sounds good to me. I like the idea that the automatic refresh could be enabled via a CiviMail setting - this keeps everyone happy (although it does add some overhead). When the auto-refresh is enabled the 'refresh' button would ideally be hidden. |
76843df
to
71c4245
Compare
Thanks @monishdeb . I haven't tested the patch, but the screencast you prepared looks good workflow-wise. I think the setting would make more sense 'flipped' around to 'Enable automatic recipient counting' (ticked by default). 'Enable recipient rebuild' isn't as clear as if we say 'manual' or 'automatic' explicitly? Thanks for the changes and work on this Monish! |
So picking up on @JKingsnorth points, let's
|
9e57394
to
791a258
Compare
@JoeMurray I agree with those points, and agree that it should default to automatic counts so that existing experience is maintained. I suspect the caching work @monishdeb did will alleviate some of the load even on automatic counts. We could also add a message during the upgrade process to alert people to the new setting. |
Thanks everyone, this is all sounding very positive! |
@lcdservices @JKingsnorth I have changed the setting title and set default to TRUE: |
@monishdeb implemented the PR and had a few issues:
I think that's it. the rest seems to be working correctly. |
@lcdservices I have fixed the remaining two issues, here's the screencast http://www.screencast.com/t/AzZRt9vvik . As per changes:
|
Hi @monishdeb, I have tested this patch on the site that I mentioned in CRM-21260, focusing on looking for any improvement in the speed of initialising the UI. (See also results reported for #11142.) Previous testing for CRM-21260 showed that the number of message templates makes a big difference. So I tested with & without the patch and with different numbers of message templates enabled (all vs just the reserved ones). 3 trials in each condition. Results - initialisation speedTesting 4.7.26RC-201710090252 without patchMessage templates: 31: Message templates: 1212: Testing 4.7.26RC-201710090252 + PR 11091Auto recipient count update disabled. Message templates: 31: Message templates: 1212: Results Summary - initialisation speedNot a significant difference in the time to initialise the UI (before selecting any recipients), which is the thing I'm focusing on here. (Slightly faster with 31 templates, slightly slower with 1212.) I appreciate that the patch is mainly aimed at improving performance once the user starts selecting recipients, so these results don't go against that. Testing the new functionalityI had a bit of a shock the first time I measured the time to populate the count with automatic CiviMail recipient count display disabled, using a static mailing group with 150k contacts: it took 28 minutes. 26 minutes of that was a ROLLBACK query. Subsequent trials were much faster though, 45-60 seconds, whether the automatic count was disabled or enabled. The civicrm_mailing_recipients table in this db has 54 million records, so I'm assuming the slow first time was due to this table warming up. I think disabling automatic CiviMail recipient count display should reduce server load when selecting multiple large recipient groups for a mailing. Issues encountered:While the CiviMail compose form is loading, the count displays as ~%1 recipients . This happens whether automatic CiviMail recipient count display is enabled or disabled. With automatic CiviMail recipient count display enabled, after selecting a recipient group there is no visual feedback that the count is being calculated, it kept showing "No recipients" until the count was populated, even though the query was in progress. Similarly if the count has populated for the first group selected and is now being re-calculated when a second group is added, there is no indication that the count is being updated. If this takes some time, which it can for large groups or complex smart groups, then the user could be misled into thinking thinking they are mailing 100 people when it's actually 150k. When the Estimate Recipient Count button has focus / is highlighted, the top of the highlight border is hidden behind the Recipients field (Chrome on Mac). Maybe add a little spacing above the button? |
Thanks for the detailed analysis @davejenx - the thing that stood out for me was what you found about the ROLLBACK taking ages. We've also noticed this, though I haven't run such detailed analysis on it. This is due to the way recipients are calculated (generate the recipients rows, get the count, then rollback) see https://issues.civicrm.org/jira/browse/CRM-21368. |
@JKingsnorth please look at my other PR #11142 ( at L319) which removes the rollback logic from angular js. As per the patch we are not doing any rollback but refreshing the recipient list whenever angularJs services are called to fetch recipient count/list. @davejenx thanks for your feedback but this patch doesn't improve the initialization speed. It improves the speed during mail compose, by storing the recipient data in cache. And this feature is controlled by a CiviMail component setting |
@monishdeb Cool I'll take a look, sorry I missed this, thanks! |
@monishdeb Only the first half of my comment was about initialisation speed and as I said, "I appreciate that the patch is mainly aimed at improving performance once the user starts selecting recipients, so these results don't go against that." |
@davejenx sorry I didn't give reply to the "Issues encountered", after reading your comment I found three issues as per your feedback, let me cover each pointwise:
I have fixed this issue and this is the commit -79e7971 . So now if the setting is disabled then it won't show
Unfortunately, I wasn't able to fix this yet. Will keep trying.
This is as per how other buttons are rendered just below the select2/text (like 'Send test' button below) field I kept the same format but I agree with you that a little space above the button would be cleaner to represent. Will bring this changes too. |
'html_type' => 'checkbox', | ||
'title' => ts('Enable automatic CiviMail recipient count display'), | ||
'weight' => 12, | ||
'description' => 'Enable this setting to rebuild recipient list automatically during composing mail. Disable will allow you to rebuild recipient manually.', |
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.
Can you ts()
this string?
@@ -108,6 +108,12 @@ public function preProcess() { | |||
'weight' => 11, | |||
'description' => 'If enabled, a randomized hash key will be used to reference the mailing URL in the mailing.viewUrl token, instead of the mailing ID', |
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.
And this one too, even if it was not added by you. :)
'html_type' => 'checkbox', | ||
'title' => ts('Enable automatic CiviMail recipient count display'), | ||
'weight' => 12, | ||
'description' => ts('Enable this setting to rebuild recipient list automatically during composing mail. Disable will allow you to rebuild recipient manually.'), |
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.
@mlutfy I have added ts(). Thanks for notifying :) Is there anything else that needs to be done to get this PR merged?
Thanks for fixing the Merging based on the reviews so far by @davejenx @JKingsnorth @seamuslee001 @JoeMurray and @lcdservices also mentioning that they are running this patch in production. |
CRM-21279: Rebuild recipient list and calculate count on demand, store result in cache
See also #** (dev/mail/4) Recipient groups in a scheduled mail return no recipients.**, which appears to affect non-US language systems. |
Overview
In CiviMail compose screen, there are few issues with how the recipient count and list are fetched, which are:
In order to avoid such repetitive API call, a new CiviMail component setting is introduced called
auto_recipient_rebuild
which is set by default, that allows you to rebuild recipient data automatically or manually. Let me show you affect on mail screen if this new setting is enabled/disabled.Auto recipient rebuild
Manual recipient rebuild
Technical Details
The idea behind is to avoid the repetitive call to APIs and fetch recipient data on demand to improve performance, but this feature is controlled by setting ```` auto_recipient_rebuild```