Skip to content

Commit 2ff47ed

Browse files
authored
Merge pull request #16361 from Godmartinz/acceptancer_reminder_unlisted_email_info
Fixed acceptance reminder command lag on users with no associated email
2 parents d923d29 + 899119a commit 2ff47ed

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

app/Console/Commands/SendAcceptanceReminder.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function handle()
6464
->groupBy(function($item) {
6565
return $item['acceptance']->assignedTo ? $item['acceptance']->assignedTo->id : '';
6666
});
67+
$no_email_list= [];
6768

6869
foreach($unacceptedAssetGroups as $unacceptedAssetGroup) {
6970
// The [0] is weird, but it allows for the item_count to work and grabs the appropriate info for each user.
@@ -72,7 +73,10 @@ public function handle()
7273
$locale = $acceptance->assignedTo?->locale;
7374
$email = $acceptance->assignedTo?->email;
7475
if(!$email){
75-
$this->info($acceptance->assignedTo?->present()->fullName().' has no email address.');
76+
$no_email_list[] = [
77+
'id' => $acceptance->assignedTo->id,
78+
'name' => $acceptance->assignedTo->present()->fullName(),
79+
];
7680
}
7781
$item_count = $unacceptedAssetGroup->count();
7882

@@ -86,6 +90,14 @@ public function handle()
8690
}
8791

8892
$this->info($count.' users notified.');
93+
$headers = ['ID', 'Name'];
94+
$rows = [];
95+
96+
foreach ($no_email_list as $user) {
97+
$rows[] = [$user['id'], $user['name']];
98+
}
99+
$this->info("The following users do not have an email address:");
100+
$this->table($headers, $rows);
89101

90102
return 0;
91103
}

tests/Feature/Console/SendAcceptanceReminderTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ public function testAcceptanceReminderCommandHandlesUserWithoutEmail()
4343
CheckoutAcceptance::factory()->pending()->create([
4444
'assigned_to_id' => $userA->id,
4545
]);
46-
46+
$headers = ['ID', 'Name'];
47+
$rows = [
48+
[$userA->id, $userA->present()->fullName()],
49+
];
4750
$this->artisan('snipeit:acceptance-reminder')
48-
->expectsOutput($userA->present()->fullName().' has no email address.')
51+
->expectsOutput("The following users do not have an email address:")
52+
->expectsTable($headers, $rows)
4953
->assertExitCode(0);
5054

5155
Mail::assertNotSent(UnacceptedAssetReminderMail::class);

0 commit comments

Comments
 (0)