Skip to content

Commit f3e2774

Browse files
committed
Use config
1 parent ee15c05 commit f3e2774

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

app/Http/Controllers/DashboardStatsController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,33 @@ class DashboardStatsController extends Controller
1010
{
1111
public function index() {
1212

13-
$flowsPastHour = StoredWorkflow::where('updated_at', '>=', now()->subHour())
13+
$flowsPastHour = config('workflows.stored_workflow_model', StoredWorkflow::class)::where('updated_at', '>=', now()->subHour())
1414
->count();
1515

16-
$exceptionsPastHour = StoredWorkflowException::where('created_at', '>=', now()->subHour())
16+
$exceptionsPastHour = config('workflows.stored_workflow_exception_model', StoredWorkflowException::class)::where('created_at', '>=', now()->subHour())
1717
->count();
1818

19-
$failedFlowsPastWeek = StoredWorkflow::where('status', 'failed')
19+
$failedFlowsPastWeek = config('workflows.stored_workflow_model', StoredWorkflow::class)::where('status', 'failed')
2020
->where('updated_at', '>=', now()->subDays(7))
2121
->count();
2222

23-
$maxWaitTimeWorkflow = StoredWorkflow::where('status', 'pending')
23+
$maxWaitTimeWorkflow = config('workflows.stored_workflow_model', StoredWorkflow::class)::where('status', 'pending')
2424
->orderBy('updated_at')
2525
->first();
2626

27-
$maxDurationWorkflow = StoredWorkflow::select('*')
27+
$maxDurationWorkflow = config('workflows.stored_workflow_model', StoredWorkflow::class)::select('*')
2828
->addSelect(DB::raw('TIMEDIFF(created_at, updated_at) as duration'))
2929
->where('status', '!=', 'pending')
3030
->orderBy('duration')
3131
->first();
3232

33-
$maxExceptionsWorkflow = StoredWorkflow::withCount('exceptions')
33+
$maxExceptionsWorkflow = config('workflows.stored_workflow_model', StoredWorkflow::class)::withCount('exceptions')
3434
->orderByDesc('exceptions_count')
3535
->orderByDesc('updated_at')
3636
->first();
3737

3838
return response()->json([
39-
'flows' => StoredWorkflow::count(),
39+
'flows' => config('workflows.stored_workflow_model', StoredWorkflow::class)::count(),
4040
'flows_per_minute' => $flowsPastHour / 60,
4141
'flows_past_hour' => $flowsPastHour,
4242
'exceptions_past_hour' => $exceptionsPastHour,

app/Http/Controllers/WorkflowsController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
class WorkflowsController extends Controller
99
{
1010
public function completed() {
11-
return StoredWorkflow::whereStatus('completed')
11+
return config('workflows.stored_workflow_model', StoredWorkflow::class)::whereStatus('completed')
1212
->orderByDesc('id')
1313
->paginate(50);
1414
}
1515

1616
public function failed() {
17-
return StoredWorkflow::whereStatus('failed')
17+
return config('workflows.stored_workflow_model', StoredWorkflow::class)::whereStatus('failed')
1818
->orderByDesc('id')
1919
->paginate(50);
2020
}
2121

2222
public function running() {
23-
return StoredWorkflow::whereIn('status', [
23+
return config('workflows.stored_workflow_model', StoredWorkflow::class)::whereIn('status', [
2424
'created',
2525
'pending',
2626
'running',
@@ -31,7 +31,7 @@ public function running() {
3131
}
3232

3333
public function show($id) {
34-
$flow = StoredWorkflow::whereId($id)->with(['exceptions', 'logs'])->first();
34+
$flow = config('workflows.stored_workflow_model', StoredWorkflow::class)::whereId($id)->with(['exceptions', 'logs'])->first();
3535

3636
$flow->exceptions = $flow->exceptions->map(function ($exception) {
3737
$unserialized = unserialize($exception->exception);

0 commit comments

Comments
 (0)