feat: report the source export timestamp on every travel export page
This commit is contained in:
1 parent
c2c55bc8b2
commit
272c811f4f
6 files changed
+49
-5
No files matched your search
@@ -59,6 +59,7 @@ class ExportController extends AbstractController
|
||||
'totalPages' => (int) ceil($total / $query->perPage),
|
||||
'skipped' => $export->skipped,
|
||||
'pickupsWithoutMasterData' => $export->pickupsWithoutMasterData,
|
||||
'sourceGeneratedAt' => $export->sourceGeneratedAt?->format('c'),
|
||||
'generatedAt' => $export->generatedAt->format('c'),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -19,12 +19,14 @@ final readonly class TravelExport
|
||||
* @param list<array<string, mixed>> $rows one row per (travel, hotel) pair
|
||||
* @param int $skipped (travel, hotel) pairs dropped as unusable
|
||||
* @param int $pickupsWithoutMasterData distinct pickup ids absent from zustiege.xml
|
||||
* @param \DateTimeImmutable|null $sourceGeneratedAt the uebertragung.info timestamp of the export read, null if unknown
|
||||
*/
|
||||
public function __construct(
|
||||
public array $rows,
|
||||
public int $skipped,
|
||||
public int $pickupsWithoutMasterData,
|
||||
public \DateTimeImmutable $generatedAt,
|
||||
public ?\DateTimeImmutable $sourceGeneratedAt = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ namespace App\Service;
|
||||
|
||||
use App\BusProNet\Model\Hotel;
|
||||
use App\BusProNet\Model\Pickup;
|
||||
use App\BusProNet\Model\XmlExportInfo;
|
||||
use App\BusProNet\Traits\TypeConversionTrait;
|
||||
use App\BusProNet\XmlCrawlerFactory;
|
||||
use App\BusProNet\XmlLoader\HotelLoader;
|
||||
@@ -67,6 +68,11 @@ class TravelExportBuilder
|
||||
|
||||
private function assemble(): TravelExport
|
||||
{
|
||||
// Read before the walk and cached with the rows, so every page served from this
|
||||
// copy names the same source export. A client that sees it change between pages
|
||||
// knows xml-sync swapped the export underneath its walk.
|
||||
$sourceGeneratedAt = XmlExportInfo::fromStorage($this->xmlExport)?->lastTransfer;
|
||||
|
||||
$hotels = $this->hotelLoader->loadAll();
|
||||
$pickupMasterData = $this->pickupLoader->loadAll();
|
||||
|
||||
@@ -96,6 +102,7 @@ class TravelExportBuilder
|
||||
$skipped,
|
||||
count($pickupsWithoutMasterData),
|
||||
new \DateTimeImmutable(),
|
||||
$sourceGeneratedAt,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user