@@ -58,7 +58,9 @@ public function index() {
5858 ]);
5959 })
6060 ->first ();
61- $ maxDurationWorkflow ->id = $ maxDurationWorkflow ->_id ;
61+ if ($ maxDurationWorkflow ) {
62+ $ maxDurationWorkflow ->id = $ maxDurationWorkflow ->_id ;
63+ }
6264 } else {
6365 $ maxDurationWorkflow = config ('workflows.stored_workflow_model ' , StoredWorkflow::class)::select ('* ' )
6466 ->when ($ dbDriverName === 'sqlite ' , function ($ q ) {
@@ -79,21 +81,24 @@ public function index() {
7981 }
8082
8183 if ($ dbDriverName === 'mongodb ' ) {
82- $ maxExceptionsWorkflow = null ;
83-
84- $ mostExceptionWorkflowId = StoredWorkflowException::raw (function ($ collection ) {
84+ $ maxExceptionsWorkflow = StoredWorkflowException::raw (function ($ collection ) {
8585 return $ collection ->aggregate ([
8686 ['$group ' => ['_id ' => '$stored_workflow_id ' , 'count ' => ['$sum ' => 1 ]]],
8787 ['$sort ' => ['count ' => -1 ]],
8888 ['$limit ' => 1 ]
8989 ]);
90- })->first ()[ ' _id ' ] ;
90+ })->first ();
9191
92- $ maxExceptionsWorkflow = StoredWorkflow::where ('_id ' , $ mostExceptionWorkflowId )->first ();
92+ if ($ maxExceptionsWorkflow ) {
93+ $ mostExceptionWorkflowId = $ maxExceptionsWorkflow ['_id ' ];
9394
94- $ maxExceptionsWorkflow-> exceptions_count = StoredWorkflowException ::where ('stored_workflow_id ' , $ mostExceptionWorkflowId )->count ();
95+ $ maxExceptionsWorkflow = StoredWorkflow ::where ('_id ' , $ mostExceptionWorkflowId )->first ();
9596
96- $ maxExceptionsWorkflow ->id = $ maxExceptionsWorkflow ->_id ;
97+ if ($ maxExceptionsWorkflow ) {
98+ $ maxExceptionsWorkflow ->exceptions_count = StoredWorkflowException::where ('stored_workflow_id ' , $ mostExceptionWorkflowId )->count ();
99+ $ maxExceptionsWorkflow ->id = $ maxExceptionsWorkflow ->_id ;
100+ }
101+ }
97102 } else {
98103 $ maxExceptionsWorkflow = config ('workflows.stored_workflow_model ' , StoredWorkflow::class)::withCount ('exceptions ' )
99104 ->has ('exceptions ' )
0 commit comments