-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/inikoo/aiku into main
- Loading branch information
Showing
49 changed files
with
660 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/Actions/Comms/DispatchedEmail/Hydrators/DispatchedEmailHydrateEmailTracking.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Artha <artha@aw-advantage.com> | ||
* Created: Thu, 20 Feb 2025 13:37:24 Central Indonesia Time, Sanur, Bali, Indonesia | ||
* Copyright (c) 2025, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Actions\Comms\DispatchedEmail\Hydrators; | ||
|
||
use App\Actions\Traits\WithEnumStats; | ||
use App\Enums\Comms\EmailTrackingEvent\EmailTrackingEventTypeEnum; | ||
use App\Models\Comms\DispatchedEmail; | ||
use Illuminate\Queue\Middleware\WithoutOverlapping; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
|
||
class DispatchedEmailHydrateEmailTracking | ||
{ | ||
use AsAction; | ||
use WithEnumStats; | ||
|
||
private DispatchedEmail $dispatchedEmail; | ||
|
||
public function __construct(DispatchedEmail $dispatchedEmail) | ||
{ | ||
$this->dispatchedEmail = $dispatchedEmail; | ||
} | ||
|
||
public function getJobMiddleware(): array | ||
{ | ||
return [(new WithoutOverlapping($this->dispatchedEmail->id))->dontRelease()]; | ||
} | ||
|
||
|
||
public function handle(DispatchedEmail $dispatchedEmail): void | ||
{ | ||
$stats = [ | ||
'number_clicks' => $dispatchedEmail | ||
->emailTrackingEvents() | ||
->where('type', EmailTrackingEventTypeEnum::CLICKED) | ||
->count(), | ||
'number_reads' => $dispatchedEmail | ||
->emailTrackingEvents() | ||
->where('type', EmailTrackingEventTypeEnum::OPENED) | ||
->count() | ||
]; | ||
|
||
$dispatchedEmail->update($stats); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.