mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-12 01:54:41 +08:00
Fix some cases of database download in GeolocationDbUpdater
This commit is contained in:
@@ -49,17 +49,11 @@ class GeolocationDbUpdate extends AbstractEntity
|
||||
}
|
||||
|
||||
/**
|
||||
* This update would require a new download if:
|
||||
* - It is successful and older than 30 days
|
||||
* - It is error and older than 2 days
|
||||
* @param positive-int $days
|
||||
*/
|
||||
public function needsUpdate(): bool
|
||||
public function isOlderThan(int $days): bool
|
||||
{
|
||||
return match ($this->status) {
|
||||
GeolocationDbUpdateStatus::SUCCESS => Chronos::now()->greaterThan($this->dateUpdated->addDays(30)),
|
||||
GeolocationDbUpdateStatus::ERROR => Chronos::now()->greaterThan($this->dateUpdated->addDays(2)),
|
||||
default => false,
|
||||
};
|
||||
return Chronos::now()->greaterThan($this->dateUpdated->addDays($days));
|
||||
}
|
||||
|
||||
public function isInProgress(): bool
|
||||
@@ -71,4 +65,9 @@ class GeolocationDbUpdate extends AbstractEntity
|
||||
{
|
||||
return $this->status === GeolocationDbUpdateStatus::ERROR;
|
||||
}
|
||||
|
||||
public function isSuccess(): bool
|
||||
{
|
||||
return $this->status === GeolocationDbUpdateStatus::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user