Fix SimBriefService (#1209)
* Fix removeExpiredEntires() * Fix SimBriefTest No need to add `'pirep_id' => ''` , just let it be `null` (like the core code does) and no need to convert Carbon to DateTimeString.
This commit is contained in:
parent
11cebb3e6e
commit
5b10dca868
@ -192,11 +192,11 @@ class SimBriefService extends Service
|
||||
public function removeExpiredEntries(): void
|
||||
{
|
||||
$expire_days = setting('simbrief.expire_days', 5);
|
||||
$expire_time = Carbon::now('UTC')->subDays($expire_days)->toDateTimeString();
|
||||
$expire_time = Carbon::now('UTC')->subDays($expire_days);
|
||||
|
||||
$briefs = SimBrief::where([
|
||||
['pirep_id', '=', ''],
|
||||
['created_at', '<', $expire_time],
|
||||
['pirep_id', null],
|
||||
['created_at', '<=', $expire_time],
|
||||
])->get();
|
||||
|
||||
foreach ($briefs as $brief) {
|
||||
|
@ -336,14 +336,13 @@ class SimBriefTest extends TestCase
|
||||
'user_id' => $user->id,
|
||||
'flight_id' => 'a_flight_id',
|
||||
'pirep_id' => 'a_pirep_id',
|
||||
'created_at' => Carbon::now('UTC')->subDays(6)->toDateTimeString(),
|
||||
'created_at' => Carbon::now('UTC')->subDays(6),
|
||||
]);
|
||||
|
||||
factory(SimBrief::class)->create([
|
||||
'user_id' => $user->id,
|
||||
'flight_id' => 'a_flight_Id',
|
||||
'pirep_id' => '',
|
||||
'created_at' => Carbon::now('UTC')->subDays(6)->toDateTimeString(),
|
||||
'created_at' => Carbon::now('UTC')->subDays(6),
|
||||
]);
|
||||
|
||||
/** @var SimBriefService $sb */
|
||||
|
Loading…
Reference in New Issue
Block a user