mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Remove dead code that is affecting code coverage
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Spec;
|
||||
|
||||
use Happyr\DoctrineSpecification\Spec;
|
||||
use Happyr\DoctrineSpecification\Specification\BaseSpecification;
|
||||
use Happyr\DoctrineSpecification\Specification\Specification;
|
||||
use Shlinkio\Shlink\Common\Util\DateRange;
|
||||
|
||||
class InDateRange extends BaseSpecification
|
||||
{
|
||||
public function __construct(private DateRange|null $dateRange, private string $field = 'date')
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function getSpec(): Specification
|
||||
{
|
||||
$criteria = [];
|
||||
|
||||
if ($this->dateRange?->startDate !== null) {
|
||||
$criteria[] = Spec::gte($this->field, $this->dateRange->startDate->toDateTimeString());
|
||||
}
|
||||
|
||||
if ($this->dateRange?->endDate !== null) {
|
||||
$criteria[] = Spec::lte($this->field, $this->dateRange->endDate->toDateTimeString());
|
||||
}
|
||||
|
||||
return Spec::andX(...$criteria);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class Visit extends AbstractEntity implements JsonSerializable
|
||||
remoteAddr: self::processAddress($visitor->remoteAddress, $anonymize),
|
||||
visitedUrl: $visitor->visitedUrl,
|
||||
redirectUrl: $visitor->redirectUrl,
|
||||
visitLocation: $geolocation !== null ? VisitLocation::fromGeolocation($geolocation) : null,
|
||||
visitLocation: $geolocation !== null ? VisitLocation::fromLocation($geolocation) : null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class Visit extends AbstractEntity implements JsonSerializable
|
||||
referer: $importedVisit->referer,
|
||||
potentialBot: isCrawler($importedVisit->userAgent),
|
||||
visitedUrl: $importedVisit instanceof ImportedShlinkOrphanVisit ? $importedVisit->visitedUrl : null,
|
||||
visitLocation: $importedLocation !== null ? VisitLocation::fromImport($importedLocation) : null,
|
||||
visitLocation: $importedLocation !== null ? VisitLocation::fromLocation($importedLocation) : null,
|
||||
date: normalizeDate($importedVisit->date),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,29 +33,16 @@ class VisitLocation extends AbstractEntity implements JsonSerializable
|
||||
);
|
||||
}
|
||||
|
||||
public static function fromGeolocation(Location $location): self
|
||||
public static function fromLocation(Location|ImportedShlinkVisitLocation $location): self
|
||||
{
|
||||
return new self(
|
||||
countryCode: $location->countryCode,
|
||||
countryName: $location->countryName,
|
||||
regionName: $location->regionName,
|
||||
cityName: $location->city,
|
||||
cityName: $location instanceof Location ? $location->city : $location->cityName,
|
||||
latitude: $location->latitude,
|
||||
longitude: $location->longitude,
|
||||
timezone: $location->timeZone,
|
||||
);
|
||||
}
|
||||
|
||||
public static function fromImport(ImportedShlinkVisitLocation $location): self
|
||||
{
|
||||
return new self(
|
||||
countryCode: $location->countryCode,
|
||||
countryName: $location->countryName,
|
||||
regionName: $location->regionName,
|
||||
cityName: $location->cityName,
|
||||
latitude: $location->latitude,
|
||||
longitude: $location->longitude,
|
||||
timezone: $location->timezone,
|
||||
timezone: $location instanceof Location ? $location->timeZone : $location->timezone,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ readonly class VisitLocator implements VisitLocatorInterface
|
||||
$location = Location::empty();
|
||||
}
|
||||
|
||||
$this->locateVisit($visit, VisitLocation::fromGeolocation($location), $helper);
|
||||
$this->locateVisit($visit, VisitLocation::fromLocation($location), $helper);
|
||||
|
||||
// Flush and clear after X iterations
|
||||
if ($count % $persistBlock === 0) {
|
||||
|
||||
Reference in New Issue
Block a user