Remove dead code that is affecting code coverage

This commit is contained in:
Alejandro Celaya
2025-11-17 12:12:06 +01:00
parent c8537e4f71
commit 0604237b94
15 changed files with 46 additions and 66 deletions

View File

@@ -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);
}
}

View File

@@ -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),
);
}

View File

@@ -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,
);
}

View File

@@ -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) {