Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/MailQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Copy link
Member

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.

Copy link
Member

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. 🤔

Copy link
Contributor Author

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.

Copy link
Member

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 🙈

} else if ($restrictEmails === UserSettings::EMAIL_SEND_DAILY) {
$query->where($query->expr()->eq('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' + ' . 3600 * 24)));
$query->where($query->expr()->eq('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' - ' . 3600 * 24)));
} else if ($restrictEmails === UserSettings::EMAIL_SEND_WEEKLY) {
$query->where($query->expr()->eq('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' + ' . 3600 * 24 * 7)));
$query->where($query->expr()->eq('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' - ' . 3600 * 24 * 7)));
} else if ($restrictEmails === UserSettings::EMAIL_SEND_ASAP) {
$query->where($query->expr()->eq('amq_timestamp', 'amq_latest_send'));
}
Expand Down