Merged in fix/warmup-autocomplete-data (pull request #2212)
warmup autocomplete data * warmup autocomplete data Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
|
||||
import { warmupAutoComplete } from "./wamupAutoCompleteLocations"
|
||||
import { warmupCountry } from "./warmupCountries"
|
||||
import { warmupHotelData } from "./warmupHotelData"
|
||||
import { warmupHotelIdsByCountry } from "./warmupHotelIdsByCountry"
|
||||
@@ -35,6 +36,13 @@ export const warmupFunctions: Record<WarmupFunctionsKey, WarmupFunction> = {
|
||||
hotelData_fi: warmupHotelData(Lang.fi),
|
||||
hotelData_sv: warmupHotelData(Lang.sv),
|
||||
hotelData_no: warmupHotelData(Lang.no),
|
||||
|
||||
autoComplete_en: warmupAutoComplete(Lang.en),
|
||||
autoComplete_da: warmupAutoComplete(Lang.da),
|
||||
autoComplete_de: warmupAutoComplete(Lang.de),
|
||||
autoComplete_fi: warmupAutoComplete(Lang.fi),
|
||||
autoComplete_sv: warmupAutoComplete(Lang.sv),
|
||||
autoComplete_no: warmupAutoComplete(Lang.no),
|
||||
}
|
||||
|
||||
export async function warmup(key: WarmupFunctionsKey): Promise<WarmupResult> {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { getAutoCompleteDestinationsData } from "@/server/routers/autocomplete/destinations"
|
||||
import { getServiceToken } from "@/server/tokenManager"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { WarmupFunction, WarmupResult } from "."
|
||||
|
||||
export const warmupAutoComplete =
|
||||
(lang: Lang): WarmupFunction =>
|
||||
async (): Promise<WarmupResult> => {
|
||||
try {
|
||||
const serviceToken = await getServiceToken()
|
||||
await getAutoCompleteDestinationsData({
|
||||
lang,
|
||||
serviceToken: serviceToken.access_token,
|
||||
warmup: true,
|
||||
})
|
||||
} catch (error) {
|
||||
return {
|
||||
status: "error",
|
||||
error: error as Error,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
status: "completed",
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ export const warmupKeys = [
|
||||
...langs.map((lang) => `countries_${lang}` as const),
|
||||
"hotelsByCountry",
|
||||
...langs.map((lang) => `hotelData_${lang}` as const),
|
||||
...langs.map((lang) => `autoComplete_${lang}` as const),
|
||||
] as const
|
||||
|
||||
export type WarmupFunctionsKey = (typeof warmupKeys)[number]
|
||||
|
||||
Reference in New Issue
Block a user