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:
B.Fatih KOZ 2021-05-27 16:27:38 +03:00 committed by GitHub
parent 11cebb3e6e
commit 5b10dca868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -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) {

View File

@ -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 */