include partial fuel up fuel consumption in average mpg.
This commit is contained in:
@@ -11,12 +11,13 @@ namespace CarCareTracker.Helper
|
|||||||
{
|
{
|
||||||
public string GetAverageGasMileage(List<GasRecordViewModel> results, bool useMPG)
|
public string GetAverageGasMileage(List<GasRecordViewModel> results, bool useMPG)
|
||||||
{
|
{
|
||||||
var recordWithCalculatedMPG = results.Where(x => x.MilesPerGallon > 0);
|
var recordsToCalculateGallons = results.Where(x => x.MilesPerGallon > 0 || !x.IsFillToFull);
|
||||||
|
var recordWithCalculatedMPG = recordsToCalculateGallons.Where(x => x.MilesPerGallon > 0);
|
||||||
var minMileage = results.Min(x => x.Mileage);
|
var minMileage = results.Min(x => x.Mileage);
|
||||||
if (recordWithCalculatedMPG.Any())
|
if (recordWithCalculatedMPG.Any())
|
||||||
{
|
{
|
||||||
var maxMileage = recordWithCalculatedMPG.Max(x => x.Mileage);
|
var maxMileage = recordWithCalculatedMPG.Max(x => x.Mileage);
|
||||||
var totalGallonsConsumed = recordWithCalculatedMPG.Sum(x => x.Gallons);
|
var totalGallonsConsumed = recordsToCalculateGallons.Sum(x => x.Gallons);
|
||||||
var deltaMileage = maxMileage - minMileage;
|
var deltaMileage = maxMileage - minMileage;
|
||||||
var averageGasMileage = (maxMileage - minMileage) / totalGallonsConsumed;
|
var averageGasMileage = (maxMileage - minMileage) / totalGallonsConsumed;
|
||||||
if (!useMPG)
|
if (!useMPG)
|
||||||
|
|||||||
@@ -154,7 +154,7 @@
|
|||||||
<img src="/defaults/lubelogger_logo.png" />
|
<img src="/defaults/lubelogger_logo.png" />
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
<small class="text-body-secondary">Version 1.0.8</small>
|
<small class="text-body-secondary">Version 1.0.9</small>
|
||||||
</div>
|
</div>
|
||||||
<p class="lead">
|
<p class="lead">
|
||||||
Proudly developed in the rural town of Price, Utah by Hargata Softworks.
|
Proudly developed in the rural town of Price, Utah by Hargata Softworks.
|
||||||
|
|||||||
Reference in New Issue
Block a user