Skip to content

Commit fa66ade

Browse files
committed
Support MySQL and PostgreSQL
1 parent 123c3cf commit fa66ade

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/Http/Controllers/DashboardStatsController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ public function index() {
2525
->first();
2626

2727
$maxDurationWorkflow = config('workflows.stored_workflow_model', StoredWorkflow::class)::select('*')
28-
->addSelect(DB::raw('(EXTRACT(EPOCH FROM created_at - updated_at)) as duration'))
28+
->when(config('database.default') === 'mysql', function ($q) {
29+
return $q->addSelect(DB::raw('TIMEDIFF(created_at, updated_at) as duration'));
30+
})
31+
->when(config('database.default') === 'pgsql', function ($q) {
32+
return $q->addSelect(DB::raw('(EXTRACT(EPOCH FROM created_at - updated_at)) as duration'));
33+
})
2934
->where('status', '!=', 'pending')
3035
->orderBy('duration')
3136
->first();

0 commit comments

Comments
 (0)