mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-22 08:56:42 -06:00
Updated amount of days to wait for the GeoLite2 database to be updated
This commit is contained in:
parent
0f48dd567f
commit
6613cb5c60
@ -30,7 +30,7 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
|
||||
{
|
||||
try {
|
||||
$meta = $this->geoLiteDbReader->metadata();
|
||||
if ($this->buildIsOlderThanOneWeek($meta->__get('buildEpoch'))) {
|
||||
if ($this->buildIsTooOld($meta->__get('buildEpoch'))) {
|
||||
$this->downloadNewDb(true, $mustBeUpdated, $handleProgress);
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
@ -39,11 +39,11 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function buildIsOlderThanOneWeek(int $buildTimestamp): bool
|
||||
private function buildIsTooOld(int $buildTimestamp): bool
|
||||
{
|
||||
$buildDate = Chronos::createFromTimestamp($buildTimestamp);
|
||||
$now = Chronos::now();
|
||||
return $now->gt($buildDate->addDays(7));
|
||||
return $now->gt($buildDate->addDays(35));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,7 +55,7 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
|
||||
callable $handleProgress = null
|
||||
): void {
|
||||
if ($mustBeUpdated !== null) {
|
||||
$mustBeUpdated();
|
||||
$mustBeUpdated($olderDbExists);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -64,7 +64,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideDaysBiggerThanSeven
|
||||
* @dataProvider provideBigDays
|
||||
*/
|
||||
public function exceptionIsThrownWhenOlderDbIsTooOldAndDownloadFails(int $days): void
|
||||
{
|
||||
@ -96,17 +96,17 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
$download->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
public function provideDaysBiggerThanSeven(): iterable
|
||||
public function provideBigDays(): iterable
|
||||
{
|
||||
yield [8];
|
||||
yield [9];
|
||||
yield [10];
|
||||
yield [36];
|
||||
yield [50];
|
||||
yield [75];
|
||||
yield [100];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideDaysSmallerThanSeven
|
||||
* @dataProvider provideSmallDays
|
||||
*/
|
||||
public function databaseIsNotUpdatedIfItIsYoungerThanOneWeek(int $days): void
|
||||
{
|
||||
@ -130,9 +130,9 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
$download->shouldNotHaveBeenCalled();
|
||||
}
|
||||
|
||||
public function provideDaysSmallerThanSeven(): iterable
|
||||
public function provideSmallDays(): iterable
|
||||
{
|
||||
return map(range(0, 6), function (int $days) {
|
||||
return map(range(0, 34), function (int $days) {
|
||||
return [$days];
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user