Skip to content

Commit cee2465

Browse files
authored
Fixes on database query and driver name. (#20)
1 parent 09524b3 commit cee2465

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/Http/Controllers/DashboardStatsController.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ public function index() {
2424
->orderBy('updated_at')
2525
->first();
2626

27-
if (config('database.default') === 'mongodb' && $maxWaitTimeWorkflow && $maxWaitTimeWorkflow->_id) {
27+
$dbDriverName = DB::connection()->getDriverName();
28+
29+
if ($dbDriverName === 'mongodb' && $maxWaitTimeWorkflow && $maxWaitTimeWorkflow->_id) {
2830
$maxWaitTimeWorkflow->id = $maxWaitTimeWorkflow->_id;
2931
}
3032

31-
if (config('database.default') === 'mongodb') {
33+
if ($dbDriverName === 'mongodb') {
3234
$maxDurationWorkflow = config('workflows.stored_workflow_model', StoredWorkflow::class)::select('*')
3335
->raw(function ($collection) {
3436
return $collection->aggregate([
@@ -59,18 +61,18 @@ public function index() {
5961
$maxDurationWorkflow->id = $maxDurationWorkflow->_id;
6062
} else {
6163
$maxDurationWorkflow = config('workflows.stored_workflow_model', StoredWorkflow::class)::select('*')
62-
->when(config('database.default') === 'mysql', function ($q) {
64+
->when($dbDriverName === 'mysql', function ($q) {
6365
return $q->addSelect(DB::raw('TIMEDIFF(created_at, updated_at) as duration'));
6466
})
65-
->when(config('database.default') === 'pgsql', function ($q) {
67+
->when($dbDriverName === 'pgsql', function ($q) {
6668
return $q->addSelect(DB::raw('(EXTRACT(EPOCH FROM created_at - updated_at)) as duration'));
6769
})
6870
->where('status', '!=', 'pending')
6971
->orderBy('duration')
7072
->first();
7173
}
7274

73-
if (config('database.default') === 'mongodb') {
75+
if ($dbDriverName === 'mongodb') {
7476
$maxExceptionsWorkflow = null;
7577

7678
$mostExceptionWorkflowId = StoredWorkflowException::raw(function ($collection) {

app/Http/Controllers/WorkflowsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function running() {
3232
}
3333

3434
public function show($id) {
35-
$flow = config('workflows.stored_workflow_model', StoredWorkflow::class)::find($id)->with(['exceptions', 'logs'])->first();
35+
$flow = config('workflows.stored_workflow_model', StoredWorkflow::class)::with(['exceptions', 'logs'])->find($id);
3636

3737
$flow->arguments = serialize(Y::unserialize($flow->arguments));
3838

0 commit comments

Comments
 (0)