- Extracts subscriber recalculation into a spearate method
- Updates subscriber recalculation logic
This commit is contained in:
@@ -55,11 +55,16 @@ class SendingQueue {
|
|||||||
$subscribers_ids) {
|
$subscribers_ids) {
|
||||||
$subscribers = Subscriber::whereIn('id', $subscribers_ids)
|
$subscribers = Subscriber::whereIn('id', $subscribers_ids)
|
||||||
->findArray();
|
->findArray();
|
||||||
// recalculate the number of subscribers if the total to process count
|
|
||||||
// does not match the number of subscribers in the database
|
|
||||||
if (count($subscribers_ids) !== count($subscribers)) {
|
if (count($subscribers_ids) !== count($subscribers)) {
|
||||||
$subscibers_to_exclude = array_diff($subscribers_ids, Helpers::arrayColumn($subscribers, 'id'));
|
$queue->subscribers->to_process = $this->recalculateSubscriberCount(
|
||||||
$queue->subscribers->to_process = array_diff($queue->subscribers->to_process, $subscibers_to_exclude);
|
Helpers::arrayColumn($subscribers, 'id'),
|
||||||
|
$subscribers_ids,
|
||||||
|
$queue->subscribers->to_process
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!count($queue->subscribers->to_process)) {
|
||||||
|
$this->updateQueue($queue);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
$queue->subscribers = call_user_func_array(
|
$queue->subscribers = call_user_func_array(
|
||||||
array(
|
array(
|
||||||
@@ -356,6 +361,12 @@ class SendingQueue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function recalculateSubscriberCount(
|
||||||
|
$found_subscriber, $existing_subscribers, $subscribers_to_process) {
|
||||||
|
$subscibers_to_exclude = array_diff($existing_subscribers, $found_subscriber);
|
||||||
|
return array_diff($subscribers_to_process, $subscibers_to_exclude);
|
||||||
|
}
|
||||||
|
|
||||||
private function joinObject($object = array()) {
|
private function joinObject($object = array()) {
|
||||||
return implode($this->divider, $object);
|
return implode($this->divider, $object);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user