feat: persist travel snapshots and refresh extended availability

This commit is contained in:
Björn Fromme
2026-03-23 17:29:10 +01:00
parent c1ab6d8687
commit bc7fb794bf
31 changed files with 2328 additions and 91 deletions
+243
View File
@@ -0,0 +1,243 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use App\Repository\TravelSnapshotRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: TravelSnapshotRepository::class)]
#[ORM\UniqueConstraint(name: 'uniq_snapshot_date_hotel', columns: ['date_id', 'hotel_id'])]
#[ORM\Index(name: 'idx_snapshot_date_code', columns: ['date_code'])]
#[ORM\Index(name: 'idx_snapshot_product_id', columns: ['product_id'])]
#[ORM\Index(name: 'idx_snapshot_date_to', columns: ['date_to'])]
#[ORM\Index(name: 'idx_snapshot_extended_refreshed_at', columns: ['extended_refreshed_at'])]
class TravelSnapshot
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'integer')]
private int $dateId;
#[ORM\Column(type: 'integer')]
private int $hotelId;
#[ORM\Column(type: 'string', length: 64, nullable: true)]
private ?string $dateCode = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $label = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $productId = null;
#[ORM\Column(type: 'string', length: 64, nullable: true)]
private ?string $productCode = null;
#[ORM\Column(type: 'string', length: 64, nullable: true)]
private ?string $hotelCode = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $hotelLabel = null;
#[ORM\Column(type: 'date_immutable', nullable: true)]
private ?\DateTimeImmutable $dateFrom = null;
#[ORM\Column(type: 'date_immutable', nullable: true)]
private ?\DateTimeImmutable $dateTo = null;
#[ORM\Column(type: 'text')]
private string $payload;
#[ORM\Column(type: 'string', length: 64)]
private string $payloadHash;
#[ORM\Column(type: 'datetime_immutable')]
private \DateTimeImmutable $capturedAt;
#[ORM\Column(type: 'datetime_immutable')]
private \DateTimeImmutable $updatedAt;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $extendedRefreshedAt = null;
public function __construct(int $dateId, int $hotelId, string $payload, string $payloadHash)
{
$now = new \DateTimeImmutable();
$this->dateId = $dateId;
$this->hotelId = $hotelId;
$this->payload = $payload;
$this->payloadHash = $payloadHash;
$this->capturedAt = $now;
$this->updatedAt = $now;
}
public function getId(): ?int
{
return $this->id;
}
public function getDateId(): int
{
return $this->dateId;
}
public function getHotelId(): int
{
return $this->hotelId;
}
public function getDateCode(): ?string
{
return $this->dateCode;
}
public function setDateCode(?string $dateCode): static
{
$this->dateCode = $dateCode;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): static
{
$this->label = $label;
return $this;
}
public function getProductId(): ?int
{
return $this->productId;
}
public function setProductId(?int $productId): static
{
$this->productId = $productId;
return $this;
}
public function getProductCode(): ?string
{
return $this->productCode;
}
public function setProductCode(?string $productCode): static
{
$this->productCode = $productCode;
return $this;
}
public function getHotelCode(): ?string
{
return $this->hotelCode;
}
public function setHotelCode(?string $hotelCode): static
{
$this->hotelCode = $hotelCode;
return $this;
}
public function getHotelLabel(): ?string
{
return $this->hotelLabel;
}
public function setHotelLabel(?string $hotelLabel): static
{
$this->hotelLabel = $hotelLabel;
return $this;
}
public function getDateFrom(): ?\DateTimeImmutable
{
return $this->dateFrom;
}
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
{
$this->dateFrom = $dateFrom;
return $this;
}
public function getDateTo(): ?\DateTimeImmutable
{
return $this->dateTo;
}
public function setDateTo(?\DateTimeImmutable $dateTo): static
{
$this->dateTo = $dateTo;
return $this;
}
public function getPayload(): string
{
return $this->payload;
}
public function setPayload(string $payload): static
{
$this->payload = $payload;
return $this;
}
public function getPayloadHash(): string
{
return $this->payloadHash;
}
public function setPayloadHash(string $payloadHash): static
{
$this->payloadHash = $payloadHash;
return $this;
}
public function getCapturedAt(): \DateTimeImmutable
{
return $this->capturedAt;
}
public function getUpdatedAt(): \DateTimeImmutable
{
return $this->updatedAt;
}
public function touchUpdatedAt(): static
{
$this->updatedAt = new \DateTimeImmutable();
return $this;
}
public function getExtendedRefreshedAt(): ?\DateTimeImmutable
{
return $this->extendedRefreshedAt;
}
public function setExtendedRefreshedAt(?\DateTimeImmutable $extendedRefreshedAt): static
{
$this->extendedRefreshedAt = $extendedRefreshedAt;
return $this;
}
}