Add aggregate data table for analytics output #409
This commit is contained in:
parent
e13e3c0dd5
commit
b65893e821
2 changed files with 92 additions and 37 deletions
|
|
@ -128,6 +128,17 @@ class AnalyticsController extends Controller
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// init aggregate information
|
||||||
|
$agg_data = [];
|
||||||
|
for ($i = 0; $i < 7; $i++)
|
||||||
|
{
|
||||||
|
$agg_data[] = [
|
||||||
|
'label' => $this->weekdays[$i],
|
||||||
|
'total_jos' => 0,
|
||||||
|
'total_riders' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// reprocess weekday data to account for overlap
|
// reprocess weekday data to account for overlap
|
||||||
foreach ($hub_data as $hub_id => $one_hub)
|
foreach ($hub_data as $hub_id => $one_hub)
|
||||||
{
|
{
|
||||||
|
|
@ -162,6 +173,15 @@ class AnalyticsController extends Controller
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// agggregate weekday data
|
||||||
|
$i = 0;
|
||||||
|
foreach ($sched_res['weekday_shifts'] as $day_data)
|
||||||
|
{
|
||||||
|
$agg_data[$i]['total_jos'] += $day_data['total_jos'];
|
||||||
|
$agg_data[$i]['total_riders'] += $day_data['total_riders'];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$hub_data[$hub_id]['data_weekday'] = $chart_weekday;
|
$hub_data[$hub_id]['data_weekday'] = $chart_weekday;
|
||||||
$hub_data[$hub_id]['data_all_weekdays'] = $chart_all_weekdays;
|
$hub_data[$hub_id]['data_all_weekdays'] = $chart_all_weekdays;
|
||||||
|
|
@ -177,11 +197,14 @@ class AnalyticsController extends Controller
|
||||||
// get job orders not covered by hubs
|
// get job orders not covered by hubs
|
||||||
$not_covered = $this->generateNotCoveredData($em, $hub_coverage, $today);
|
$not_covered = $this->generateNotCoveredData($em, $hub_coverage, $today);
|
||||||
|
|
||||||
|
// error_log(print_r($agg_data, true));
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'date' => $today,
|
'date' => $today,
|
||||||
'hub_list' => $hub_data,
|
'hub_list' => $hub_data,
|
||||||
'hub_coverage' => $hub_coverage,
|
'hub_coverage' => $hub_coverage,
|
||||||
'not_covered' => $not_covered,
|
'not_covered' => $not_covered,
|
||||||
|
'agg_data' => $agg_data,
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->render('analytics/forecast_submit.html.twig', $params);
|
return $this->render('analytics/forecast_submit.html.twig', $params);
|
||||||
|
|
@ -219,7 +242,7 @@ class AnalyticsController extends Controller
|
||||||
foreach ($scheduler_data as $weekday_data)
|
foreach ($scheduler_data as $weekday_data)
|
||||||
$args[] = implode('-', $weekday_data);
|
$args[] = implode('-', $weekday_data);
|
||||||
|
|
||||||
error_log(print_r($args, true));
|
// error_log(print_r($args, true));
|
||||||
|
|
||||||
// error_log('running...' . $sched_script);
|
// error_log('running...' . $sched_script);
|
||||||
|
|
||||||
|
|
@ -230,7 +253,7 @@ class AnalyticsController extends Controller
|
||||||
error_log('SCHEDULER DID NOT RUN PROPERLY');
|
error_log('SCHEDULER DID NOT RUN PROPERLY');
|
||||||
|
|
||||||
$res = $proc->getOutput();
|
$res = $proc->getOutput();
|
||||||
error_log($res);
|
// error_log($res);
|
||||||
|
|
||||||
|
|
||||||
// segregate into weekdays
|
// segregate into weekdays
|
||||||
|
|
@ -272,7 +295,7 @@ class AnalyticsController extends Controller
|
||||||
for ($i = 1; $i < count($this->hour_shifts[$hour_shift_index]); $i++)
|
for ($i = 1; $i < count($this->hour_shifts[$hour_shift_index]); $i++)
|
||||||
$rider_hours[$this->hour_shifts[$hour_shift_index][$i]] = 1;
|
$rider_hours[$this->hour_shifts[$hour_shift_index][$i]] = 1;
|
||||||
|
|
||||||
error_log('allocating ' . $rider_count . ' for ' . $label);
|
// error_log('allocating ' . $rider_count . ' for ' . $label);
|
||||||
|
|
||||||
// add shifts to the weekday
|
// add shifts to the weekday
|
||||||
for ($i = 1; $i < count($this->day_shifts[$day_shift_index]); $i++)
|
for ($i = 1; $i < count($this->day_shifts[$day_shift_index]); $i++)
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,37 @@
|
||||||
<div id="map_coverage" style="height:600px; margin-bottom: 15px;">
|
<div id="map_coverage" style="height:600px; margin-bottom: 15px;">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="m-portlet m-portlet--mobile">
|
||||||
|
<table class="shift-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 250px;">Day</th>
|
||||||
|
<th style="width: 100px;"># JO</th>
|
||||||
|
<th style="width: 100px;"># Rider</th>
|
||||||
|
<th style="width: 100px;">JO per Rider</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for i in 0..6 %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ agg_data[i].label }}</td>
|
||||||
|
<td>{{ agg_data[i].total_jos }}</td>
|
||||||
|
<td>{{ agg_data[i].total_riders }}</td>
|
||||||
|
{% if agg_data[i].total_riders == 0 %}
|
||||||
|
<td>0</td>
|
||||||
|
{% else %}
|
||||||
|
<td>{{ (agg_data[i].total_jos / agg_data[i].total_riders) | round(1, 'common') }}</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% for hub in hub_list %}
|
{% for hub in hub_list %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xl-12">
|
<div class="col-xl-12">
|
||||||
|
|
@ -65,6 +96,41 @@
|
||||||
<div id="month-all-weekday-chart-{{ hub.id }}" style="height: 400px;">
|
<div id="month-all-weekday-chart-{{ hub.id }}" style="height: 400px;">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<table class="shift-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 250px;">Day</th>
|
||||||
|
<th style="width: 100px;"># JO</th>
|
||||||
|
<th style="width: 100px;"># Rider</th>
|
||||||
|
<th style="width: 100px;">JO per Rider</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for i in 0..6 %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ hub.data_shift[i].weekday }}</td>
|
||||||
|
<td>{{ hub.data_shift[i].total_jos }}</td>
|
||||||
|
<td>{{ hub.data_shift[i].total_riders }}</td>
|
||||||
|
{% if hub.data_shift[i].total_riders == 0 %}
|
||||||
|
<td>0</td>
|
||||||
|
{% else %}
|
||||||
|
<td>{{ (hub.data_shift[i].total_jos / hub.data_shift[i].total_riders) | round(1, 'common') }}</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
<tr>
|
||||||
|
<td>Overall</td>
|
||||||
|
<td>{{ hub.total_jos }}</td>
|
||||||
|
<td>{{ hub.total_riders }}</td>
|
||||||
|
{% if hub.total_riders == 0 %}
|
||||||
|
<td>0</td>
|
||||||
|
{% else %}
|
||||||
|
<td>{{ (hub.total_jos / hub.total_riders) | round(1, 'common') }}</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
{% for day_data in hub.data_shift %}
|
{% for day_data in hub.data_shift %}
|
||||||
<div id="shift-table-{{ hub.id }}">
|
<div id="shift-table-{{ hub.id }}">
|
||||||
<table class="shift-table">
|
<table class="shift-table">
|
||||||
|
|
@ -116,40 +182,6 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<table class="shift-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 250px;">Day</th>
|
|
||||||
<th style="width: 100px;"># JO</th>
|
|
||||||
<th style="width: 100px;"># Rider</th>
|
|
||||||
<th style="width: 100px;">JO per Rider</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for i in 0..6 %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ hub.data_shift[i].weekday }}</td>
|
|
||||||
<td>{{ hub.data_shift[i].total_jos }}</td>
|
|
||||||
<td>{{ hub.data_shift[i].total_riders }}</td>
|
|
||||||
{% if hub.data_shift[i].total_riders == 0 %}
|
|
||||||
<td>0</td>
|
|
||||||
{% else %}
|
|
||||||
<td>{{ (hub.data_shift[i].total_jos / hub.data_shift[i].total_riders) | round(1, 'common') }}</td>
|
|
||||||
{% endif %}
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
<tr>
|
|
||||||
<td>Overall</td>
|
|
||||||
<td>{{ hub.total_jos }}</td>
|
|
||||||
<td>{{ hub.total_riders }}</td>
|
|
||||||
{% if hub.total_riders == 0 %}
|
|
||||||
<td>0</td>
|
|
||||||
{% else %}
|
|
||||||
<td>{{ (hub.total_jos / hub.total_riders) | round(1, 'common') }}</td>
|
|
||||||
{% endif %}
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue