File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 44
55use Yuges \Package \Models \Model ;
66use Yuges \Processable \Config \Config ;
7+ use Yuges \Processable \Enums \StageState ;
78use Yuges \Processable \Traits \HasStages ;
9+ use Illuminate \Support \Facades \Artisan ;
810use Yuges \Processable \Traits \HasProcessable ;
911use Yuges \Processable \Traits \HasProcessState ;
1012use Illuminate \Database \Eloquent \Factories \HasFactory ;
@@ -29,4 +31,20 @@ public function getTable(): string
2931 {
3032 return Config::getProcessTable () ?? $ this ->table ;
3133 }
34+
35+ public function retry (): self
36+ {
37+ /** @var ?Stage */
38+ $ stage = $ this ->stages ()->getQuery ()
39+ ->where ('state ' , '= ' , Config::getStageStateClass (StageState::class)::Failed)
40+ ->first ();
41+
42+ if (! $ stage ?->job_uuid) {
43+ return $ this ;
44+ }
45+
46+ Artisan::call ("queue:retry {$ stage ->job_uuid }" );
47+
48+ return $ this ;
49+ }
3250}
Original file line number Diff line number Diff line change @@ -22,5 +22,7 @@ public function testProcessPost()
2222 ]);
2323
2424 $ process = $ post ->process (TestProcess::class);
25+
26+ $ process ->retry ();
2527 }
2628}
You can’t perform that action at this time.
0 commit comments