feat: increase availability cache ttl and ensure fresh data when entering form
This commit is contained in:
@@ -132,8 +132,9 @@ class Step2Controller extends AbstractController
|
|||||||
throw $this->createNotFoundException(sprintf('Participant at index %d does not exist', $index));
|
throw $this->createNotFoundException(sprintf('Participant at index %d does not exist', $index));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enrich with fresh availability data
|
// Fetch fresh availabilities when entering participant form
|
||||||
$this->travelDataService->enrichWithFreshAvailabilities($bookingDto->travel);
|
// This ensures up-to-date data and populates cache for subsequent HTMX refreshes
|
||||||
|
$this->travelDataService->enrichWithFreshAvailabilities($bookingDto->travel, cached: false);
|
||||||
|
|
||||||
// Create form with booking_context option
|
// Create form with booking_context option
|
||||||
$form = $this->createParticipantForm($bookingDto, $index);
|
$form = $this->createParticipantForm($bookingDto, $index);
|
||||||
|
|||||||
@@ -169,6 +169,10 @@ class IndexController extends AbstractController
|
|||||||
return $this->redirectToRoute('app_booking_edit', ['id' => $id]);
|
return $this->redirectToRoute('app_booking_edit', ['id' => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch fresh availabilities when entering participant form
|
||||||
|
// This ensures up-to-date data and populates cache for subsequent HTMX refreshes
|
||||||
|
$this->travelDataService->enrichWithFreshAvailabilities($bookingDto->travel, cached: false);
|
||||||
|
|
||||||
// Create wrapper DTO for email uniqueness validation
|
// Create wrapper DTO for email uniqueness validation
|
||||||
$wrapper = new ParticipantEditDto(
|
$wrapper = new ParticipantEditDto(
|
||||||
participant: $participant,
|
participant: $participant,
|
||||||
|
|||||||
@@ -523,12 +523,12 @@ class TravelDataService
|
|||||||
* Gets availability data for a travel date.
|
* Gets availability data for a travel date.
|
||||||
*
|
*
|
||||||
* @param int $dateId The travel date ID for API call
|
* @param int $dateId The travel date ID for API call
|
||||||
* @param bool $cached Whether to use cached data (default: false, TTL when cached: 60 seconds)
|
* @param bool $cached Whether to use cached data (default: false, TTL when cached: 300 seconds)
|
||||||
* @param int $ttl Cache TTL in seconds when $cached is true (default: 60 seconds)
|
* @param int $ttl Cache TTL in seconds when $cached is true (default: 300 seconds)
|
||||||
*
|
*
|
||||||
* @return ServiceAvailabilityResponse|null The availability data or null if not available or error occurred
|
* @return ServiceAvailabilityResponse|null The availability data or null if not available or error occurred
|
||||||
*/
|
*/
|
||||||
public function getAvailabilityData(int $dateId, bool $cached = false, int $ttl = 60): ?ServiceAvailabilityResponse
|
public function getAvailabilityData(int $dateId, bool $cached = false, int $ttl = 300): ?ServiceAvailabilityResponse
|
||||||
{
|
{
|
||||||
if ($cached) {
|
if ($cached) {
|
||||||
$cacheKey = sprintf('availability_%d', $dateId);
|
$cacheKey = sprintf('availability_%d', $dateId);
|
||||||
|
|||||||
Reference in New Issue
Block a user