Skip to content

Commit 4f0ed16

Browse files
Added the TrackableJobAdvanced event + the JobTracker::logs() method
1 parent 12326c7 commit 4f0ed16

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Events/TrackableJobAdvanced.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Konekt\History\Events;
6+
7+
class TrackableJobAdvanced extends BaseTrackableJobEvent
8+
{
9+
}

src/JobTracker.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
use Illuminate\Contracts\Queue\Job;
1818
use Illuminate\Support\Carbon;
19+
use Illuminate\Support\Collection;
1920
use Illuminate\Support\Facades\App;
2021
use Illuminate\Support\Facades\Auth;
2122
use Illuminate\Support\Facades\Event;
@@ -25,6 +26,7 @@
2526
use Konekt\History\Contracts\JobStatus;
2627
use Konekt\History\Contracts\SceneResolver;
2728
use Konekt\History\Contracts\TrackableJob;
29+
use Konekt\History\Events\TrackableJobAdvanced;
2830
use Konekt\History\Events\TrackableJobCompleted;
2931
use Konekt\History\Events\TrackableJobCreated;
3032
use Konekt\History\Events\TrackableJobFailed;
@@ -122,7 +124,11 @@ public function getProgressMax(): int
122124

123125
public function advance(int $steps = 1): void
124126
{
125-
$this->model()?->advance($steps);
127+
if (null !== $model = $this->model()) {
128+
$model->advance($steps);
129+
130+
Event::dispatch(new TrackableJobAdvanced($this->job));
131+
}
126132
}
127133

128134
public function getProgress(): int
@@ -163,6 +169,11 @@ public function log(string $message, string $level = LogLevel::INFO, array $cont
163169
return $log;
164170
}
165171

172+
public function logs(): Collection
173+
{
174+
return $this->model()?->getLogs() ?? collect();
175+
}
176+
166177
protected static function commonFields(TrackableJob $job): array
167178
{
168179
[$via, $scene] = static::sceneResolver()->get();

0 commit comments

Comments
 (0)