Merged in fix/destinations-speed-test (pull request #1704)

Feat(destination pages): Performance improvements

* fix/destinations: try cache full response

* Added more caching

* Removed unsed env car

* wip

* merge master

* wip

* wip

* wip

* Renaming


Approved-by: Michael Zetterberg
This commit is contained in:
Linus Flood
2025-04-02 11:37:22 +00:00
parent 961e8aea91
commit e4907d4b47
34 changed files with 381 additions and 290 deletions

View File

@@ -4,20 +4,20 @@ import type {
SortItem,
} from "@/types/components/destinationFilterAndSort"
import { SortOption } from "@/types/enums/destinationFilterAndSort"
import type { HotelDataWithUrl } from "@/types/hotel"
import type { DestinationPagesHotelData } from "@/types/hotel"
import type { DestinationCityListItem } from "@/types/trpc/routers/contentstack/destinationCityPage"
const HOTEL_SORTING_STRATEGIES: Partial<
Record<SortOption, (a: HotelDataWithUrl, b: HotelDataWithUrl) => number>
Record<
SortOption,
(a: DestinationPagesHotelData, b: DestinationPagesHotelData) => number
>
> = {
[SortOption.Name]: function (a, b) {
return a.hotel.name.localeCompare(b.hotel.name)
},
[SortOption.TripAdvisorRating]: function (a, b) {
return (
(b.hotel.ratings?.tripAdvisor.rating ?? 0) -
(a.hotel.ratings?.tripAdvisor.rating ?? 0)
)
return (b.hotel.tripadvisor ?? 0) - (a.hotel.tripadvisor ?? 0)
},
[SortOption.Distance]: function (a, b) {
return a.hotel.location.distanceToCentre - b.hotel.location.distanceToCentre
@@ -48,7 +48,7 @@ const CITY_SORTING_STRATEGIES: Partial<
}
export function getFilteredHotels(
hotels: HotelDataWithUrl[],
hotels: DestinationPagesHotelData[],
filters: string[]
) {
if (filters.length) {
@@ -62,11 +62,11 @@ export function getFilteredHotels(
}
export function getFilteredCities(
filteredHotels: HotelDataWithUrl[],
filteredHotels: DestinationPagesHotelData[],
cities: DestinationCityListItem[]
) {
const filteredCityIdentifiers = filteredHotels.map(
(hotel) => hotel.cities[0].cityIdentifier
(hotel) => hotel.hotel.cityIdentifier
)
return cities.filter((city) =>
@@ -83,7 +83,7 @@ export function getSortedCities(
}
export function getSortedHotels(
hotels: HotelDataWithUrl[],
hotels: DestinationPagesHotelData[],
sortOption: SortOption
) {
const sortFn = HOTEL_SORTING_STRATEGIES[sortOption]
@@ -116,7 +116,7 @@ const HOTEL_FACILITIES_FILTER_TYPE_NAMES = [
]
export function getFiltersFromHotels(
hotels: HotelDataWithUrl[]
hotels: DestinationPagesHotelData[]
): CategorizedFilters {
if (hotels.length === 0) {
return { facilityFilters: [], surroundingsFilters: [] }