Fix VisitIterationRepositoryTest for MS SQL

This commit is contained in:
Alejandro Celaya 2024-04-13 20:48:03 +02:00
parent f0e62004d5
commit 82e7094f3a
2 changed files with 8 additions and 8 deletions

View File

@ -51,12 +51,12 @@ class VisitIterationRepository extends EntitySpecificationRepository implements
{ {
$qb = $this->createQueryBuilder('v'); $qb = $this->createQueryBuilder('v');
if ($dateRange?->startDate !== null) { if ($dateRange?->startDate !== null) {
$qb->andWhere($qb->expr()->gte('v.date', ':since')); $qb->andWhere($qb->expr()->gte('v.date', ':since'))
$qb->setParameter('since', $dateRange->startDate, ChronosDateTimeType::CHRONOS_DATETIME); ->setParameter('since', $dateRange->startDate, ChronosDateTimeType::CHRONOS_DATETIME);
} }
if ($dateRange?->endDate !== null) { if ($dateRange?->endDate !== null) {
$qb->andWhere($qb->expr()->lte('v.date', ':until')); $qb->andWhere($qb->expr()->lte('v.date', ':until'))
$qb->setParameter('until', $dateRange->endDate, ChronosDateTimeType::CHRONOS_DATETIME); ->setParameter('until', $dateRange->endDate, ChronosDateTimeType::CHRONOS_DATETIME);
} }
return $this->visitsIterableForQuery($qb, $blockSize); return $this->visitsIterableForQuery($qb, $blockSize);

View File

@ -55,17 +55,17 @@ class VisitIterationRepositoryTest extends DatabaseTestCase
$unlocated = $this->repo->findUnlocatedVisits($blockSize); $unlocated = $this->repo->findUnlocatedVisits($blockSize);
$all = $this->repo->findAllVisits(blockSize: $blockSize); $all = $this->repo->findAllVisits(blockSize: $blockSize);
$lastThreeDays = $this->repo->findAllVisits( $lastThreeDays = $this->repo->findAllVisits(
dateRange: DateRange::since(Chronos::now()->subDays(2)), dateRange: DateRange::since(Chronos::now()->subDays(2)->startOfDay()),
blockSize: $blockSize, blockSize: $blockSize,
); );
$firstTwoDays = $this->repo->findAllVisits( $firstTwoDays = $this->repo->findAllVisits(
dateRange: DateRange::until(Chronos::now()->subDays(4)), dateRange: DateRange::until(Chronos::now()->subDays(4)->endOfDay()),
blockSize: $blockSize, blockSize: $blockSize,
); );
$daysInBetween = $this->repo->findAllVisits( $daysInBetween = $this->repo->findAllVisits(
dateRange: DateRange::between( dateRange: DateRange::between(
startDate: Chronos::now()->subDays(5), startDate: Chronos::now()->subDays(5)->startOfDay(),
endDate: Chronos::now()->subDays(2), endDate: Chronos::now()->subDays(2)->endOfDay(),
), ),
blockSize: $blockSize, blockSize: $blockSize,
); );