Add setting to include transfer hours in calculations (#350)
* Add setting to include transfer hours in calculations * Add some extra tests to check versions * A couple of more version test cases
This commit is contained in:
@@ -17,8 +17,8 @@ use App\Repositories\AircraftRepository;
|
||||
use App\Repositories\SubfleetRepository;
|
||||
use App\Support\Units\Time;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use function is_array;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class UserService
|
||||
@@ -258,7 +258,12 @@ class UserService extends Service
|
||||
return $user;
|
||||
}
|
||||
|
||||
$pilot_hours = new Time($user->flight_time);
|
||||
// If we should count their transfer hours?
|
||||
if (setting('pilots.count_transfer_hours') === true) {
|
||||
$pilot_hours = new Time($user->flight_time + $user->transfer_time);
|
||||
} else {
|
||||
$pilot_hours = new Time($user->flight_time);
|
||||
}
|
||||
|
||||
// The current rank's hours are over the pilot's current hours,
|
||||
// so assume that they were "placed" here by an admin so don't
|
||||
|
||||
@@ -179,11 +179,10 @@ class VersionService extends Service
|
||||
$current_version = $this->cleanVersionString($current_version);
|
||||
}
|
||||
|
||||
$current_version = Version::fromString($current_version);
|
||||
$latest_version = Version::fromString($this->getLatestVersion());
|
||||
$latest_version = $this->getLatestVersion();
|
||||
|
||||
// Convert to semver
|
||||
if ($latest_version->isGreaterThan($current_version)) {
|
||||
if ($this->isGreaterThan($latest_version, $current_version)) {
|
||||
$this->kvpRepo->save('new_version_available', true);
|
||||
return true;
|
||||
}
|
||||
@@ -191,4 +190,17 @@ class VersionService extends Service
|
||||
$this->kvpRepo->save('new_version_available', false);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $version1
|
||||
* @param string $version2
|
||||
*
|
||||
* @return bool If $version1 is greater than $version2
|
||||
*/
|
||||
public function isGreaterThan($version1, $version2): bool
|
||||
{
|
||||
$version1 = Version::fromString($version1);
|
||||
$version2 = Version::fromString($version2);
|
||||
return $version1->isGreaterThan($version2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user