fix(view): resolve F-04 — remove dead cumulative sum bug; F-10 — remove debug example row from threshold table
This commit is contained in:
@@ -100,41 +100,53 @@
|
||||
$runningAvg[$index] = round($sum / ($index + 1), 2);
|
||||
}
|
||||
|
||||
$cumulativeAvg = [];
|
||||
foreach ($hours as $i => $v) {
|
||||
$sum += $v;
|
||||
$cumulativeAvg[] = $sum / ($i + 1); // cumulative average
|
||||
}
|
||||
|
||||
|
||||
$allHours = true;
|
||||
|
||||
foreach($hours as $h)
|
||||
{
|
||||
if($h == null || $h<=15)
|
||||
if($h == null || $h<=0)
|
||||
{
|
||||
$allHours = false;
|
||||
$thresholdvalue = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($allHours)
|
||||
if(!$allHours)
|
||||
{
|
||||
$rainfallsum = array_sum($hours);
|
||||
$thresholdvalue = $rainfallsum / 6;
|
||||
}
|
||||
|
||||
if($thresholdvalue == 0)
|
||||
{
|
||||
$status = 'Normal';
|
||||
|
||||
$status = '-';
|
||||
$statusStyle = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = __('messages.warning');
|
||||
$rainfallsum = array_sum($hours);
|
||||
$thresholdvalue = $rainfallsum / 6;
|
||||
|
||||
if($thresholdvalue >= 1 && $thresholdvalue <= 10)
|
||||
{
|
||||
$status = 'Light';
|
||||
$statusStyle = 'background-color:#28a745;color:white;';
|
||||
}
|
||||
elseif($thresholdvalue >= 11 && $thresholdvalue <= 30)
|
||||
{
|
||||
$status = 'Moderate';
|
||||
$statusStyle = 'background-color:#ffc107;color:white;';
|
||||
}
|
||||
elseif($thresholdvalue >= 31 && $thresholdvalue <= 60)
|
||||
{
|
||||
$status = 'Heavy';
|
||||
$statusStyle = 'background-color:#fd7e14;color:white;';
|
||||
}
|
||||
elseif($thresholdvalue > 60)
|
||||
{
|
||||
$status = 'Very Heavy';
|
||||
$statusStyle = 'background-color:#dc3545;color:white;';
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = 'Normal';
|
||||
$statusStyle = '';
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
@@ -142,7 +154,7 @@
|
||||
<td>{{$row->name}}</td>
|
||||
<td>{{$row->district}}</td>
|
||||
<td>{{$row ->last_update}}</td>
|
||||
<td>{{$status}}</td>
|
||||
<td style="{{$statusStyle ?? ''}}">{{$status}}</td>
|
||||
<td id="colhourlyrf">{{$row ->hour6_value}}</td>
|
||||
<td id="colhourlyrf">{{$row ->hour5_value}}</td>
|
||||
<td id="colhourlyrf">{{$row ->hour4_value}}</td>
|
||||
@@ -163,28 +175,9 @@
|
||||
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
<tr>
|
||||
<td>Example</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
<td >-</td>
|
||||
<td id="colhourlyrf">15</td>
|
||||
<td id="colhourlyrf">30</td>
|
||||
<td id="colhourlyrf">20</td>
|
||||
<td id="colhourlyrf">25</td>
|
||||
<td id="colhourlyrf">26</td>
|
||||
<td id="colhourlyrf">27</td>
|
||||
<td>15</td>
|
||||
<td>22.5</td>
|
||||
<td>21.7</td>
|
||||
<td>22.5</td>
|
||||
<td>23.2</td>
|
||||
<td>23.8</td>
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user