When limiting the number of messages in a packet, only retrieve that number from the DB
This commit is contained in:
parent
95b6058020
commit
e692de7d7f
@ -3,6 +3,7 @@
|
|||||||
namespace App\Classes\FTN;
|
namespace App\Classes\FTN;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@ -404,9 +405,9 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
|||||||
return (string)$this;
|
return (string)$this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mail(Collection $msgs): self
|
public function mail(Builder $msgs): self
|
||||||
{
|
{
|
||||||
$this->messages = $msgs;
|
$this->messages = $msgs->get();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class MailList extends Command
|
|||||||
'from' => 'FROM',
|
'from' => 'FROM',
|
||||||
'to' => 'TO',
|
'to' => 'TO',
|
||||||
'subject' => 'SUBJECT',
|
'subject' => 'SUBJECT',
|
||||||
],$ao->netmailWaiting()->map(function($item) {
|
],$ao->netmailWaiting()->get()->map(function($item) {
|
||||||
return [
|
return [
|
||||||
'id'=>$item->id,
|
'id'=>$item->id,
|
||||||
'msgid'=>$item->msgid,
|
'msgid'=>$item->msgid,
|
||||||
@ -63,7 +63,7 @@ class MailList extends Command
|
|||||||
'to' => 'TO',
|
'to' => 'TO',
|
||||||
'subject' => 'SUBJECT',
|
'subject' => 'SUBJECT',
|
||||||
'area' => 'AREA',
|
'area' => 'AREA',
|
||||||
],$ao->echomailWaiting()->map(function($item) {
|
],$ao->echomailWaiting()->get()->map(function($item) {
|
||||||
return [
|
return [
|
||||||
'id'=>$item->id,
|
'id'=>$item->id,
|
||||||
'msgid'=>$item->msgid,
|
'msgid'=>$item->msgid,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
@ -967,9 +968,9 @@ class Address extends Model
|
|||||||
* Echomail waiting to be sent to this system
|
* Echomail waiting to be sent to this system
|
||||||
*
|
*
|
||||||
* @param int|null $max
|
* @param int|null $max
|
||||||
* @return Collection
|
* @return Builder
|
||||||
*/
|
*/
|
||||||
public function echomailWaiting(int $max=NULL): Collection
|
public function echomailWaiting(int $max=NULL): Builder
|
||||||
{
|
{
|
||||||
$echomails = $this
|
$echomails = $this
|
||||||
->UncollectedEchomail()
|
->UncollectedEchomail()
|
||||||
@ -979,7 +980,7 @@ class Address extends Model
|
|||||||
->groupBy(['echomails.id'])
|
->groupBy(['echomails.id'])
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return Echomail::whereIn('id',$echomails->pluck('id'))->get();
|
return Echomail::whereIn('id',$echomails->pluck('id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1161,10 +1162,10 @@ class Address extends Model
|
|||||||
/**
|
/**
|
||||||
* Netmail waiting to be sent to this system
|
* Netmail waiting to be sent to this system
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Builder
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function netmailWaiting(): Collection
|
public function netmailWaiting(): Builder
|
||||||
{
|
{
|
||||||
$netmails = $this
|
$netmails = $this
|
||||||
->UncollectedNetmail()
|
->UncollectedNetmail()
|
||||||
@ -1173,7 +1174,7 @@ class Address extends Model
|
|||||||
->groupBy(['netmails.id'])
|
->groupBy(['netmails.id'])
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return Netmail::whereIn('id',$netmails->pluck('id'))->get();
|
return Netmail::whereIn('id',$netmails->pluck('id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user