-
Notifications
You must be signed in to change notification settings - Fork 66
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
Correctly restrict affected users when using command to send emails #311
Conversation
… download affected users: amq_timestamp = amq_latest_send - batchtime
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.
Quite interesting that no one ever complained about this.
@@ -231,11 +231,11 @@ protected function getAffectedUsers($limit, $latestSend, $forceSending, $restric | |||
|
|||
if ($restrictEmails !== null) { | |||
if ($restrictEmails === UserSettings::EMAIL_SEND_HOURLY) { | |||
$query->where($query->expr()->lte('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' + ' . 3600))); | |||
$query->where($query->expr()->eq('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' - ' . 3600))); |
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.
ah, the lte made it execute all emails.
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.
I still don't get it. What if the batch run is one second late. Then it does not execute anymore for those users. 🤔
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.
The time of batch run does not matter. amq_timestamp
is time of an activity event, amq_latest_send
is always amq_timestamp
plus seconds that user set for its mail notification interval, so query gets only users who have any notifications and these notifications' amq_timestamp = amq_latest_send - batchtime
.
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.
Got it 👍 I misread the amq_timestamp
and amq_latest_send
as the same name 🙈
When invoking 'occ activity:send-mails ' correctly download affected users: amq_timestamp = amq_latest_send - batchtime