include partial fuel up fuel consumption in average mpg.

This commit is contained in:
DESKTOP-GENO133\IvanPlex
2024-01-25 22:18:33 -07:00
parent 331499461a
commit 31c1202649
2 changed files with 4 additions and 3 deletions

View File

@@ -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)

View File

@@ -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.