Skip to content
Snippets Groups Projects
Commit 2fef5ac7 authored by Hanif Arroisi Mukhlis's avatar Hanif Arroisi Mukhlis
Browse files

Use Left Join for Empty Results

parent 741d951a
No related merge requests found
Pipeline #49304 failed with stages
in 1 minute and 29 seconds
......@@ -44,7 +44,7 @@ class ReportController extends Controller
});
$kpis_daily =
$kpis->clone()
->joinSub(
->leftJoinSub(
$responses->clone()
->select(['kpi_id', DB::raw("AVG(actual) AS avg_actual")])
->whereDate('date', '<=', $before),
......@@ -55,7 +55,7 @@ class ReportController extends Controller
->where('period_type', '=', 'daily');
$kpis_weekly =
$kpis->clone()
->joinSub(
->leftJoinSub(
$responses->clone()
->select(['kpi_id', DB::raw("AVG(actual) AS avg_actual")])
->whereDate('date', '<=', $weekDeadline),
......@@ -66,7 +66,7 @@ class ReportController extends Controller
->where('period_type', '=', 'weekly');
$kpis_monthly =
$kpis->clone()
->joinSub(
->leftJoinSub(
$responses->clone()
->select(['kpi_id', DB::raw("AVG(actual) AS avg_actual")])
->whereDate('date', '<=', $monthDeadline),
......@@ -77,7 +77,7 @@ class ReportController extends Controller
->where('period_type', '=', 'monthly');
$kpis_custom =
$kpis->clone()
->joinSub(
->leftJoinSub(
$responses->clone()
->select(['kpi_id', DB::raw("AVG(actual) AS avg_actual")])
->whereDate('date', '<=', $before),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment