Skip to content

Commit

Permalink
Properly set the distance/planned_distance on save (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio authored Jan 14, 2020
1 parent 9aded3a commit aafc968
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/Models/Pirep.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,14 @@ public function getReadOnlyAttribute(): bool
*/
public function getProgressPercentAttribute()
{
$upper_bound = $this->distance['nmi'];
if ($this->planned_distance) {
$upper_bound = $this->planned_distance['nmi'];
}
$distance = $this->distance;

if (!$upper_bound) {
$upper_bound = 1;
$upper_bound = $distance;
if ($this->planned_distance) {
$upper_bound = $this->planned_distance;
}

return round(($this->distance['nmi'] / $upper_bound) * 100, 0);
return round(($distance / $upper_bound) * 100, 0);
}

/**
Expand Down

0 comments on commit aafc968

Please sign in to comment.