fix(SW-2921): Fixed issue with countryName missing from locations response
* fix(SW-2921): Added more correct cache key to locations endpoint Approved-by: Joakim Jäderberg Approved-by: Linus Flood
This commit is contained in:
@@ -440,7 +440,7 @@ export const locationsSchema = z.object({
|
|||||||
if (location.type === "cities") {
|
if (location.type === "cities") {
|
||||||
return {
|
return {
|
||||||
...location.attributes,
|
...location.attributes,
|
||||||
country: location?.country ?? "",
|
country: location?.countryName || "",
|
||||||
id: location.id,
|
id: location.id,
|
||||||
type: location.type,
|
type: location.type,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export const locationCitySchema = z.object({
|
|||||||
name: z.string().optional().default(""),
|
name: z.string().optional().default(""),
|
||||||
isPublished: z.boolean(),
|
isPublished: z.boolean(),
|
||||||
}),
|
}),
|
||||||
country: z.string().optional().default(""),
|
countryName: z.string().optional().default(""),
|
||||||
id: z.string().optional().default(""),
|
id: z.string().optional().default(""),
|
||||||
type: z.literal("cities"),
|
type: z.literal("cities"),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -253,8 +253,15 @@ export async function getLocations({
|
|||||||
serviceToken: string
|
serviceToken: string
|
||||||
}) {
|
}) {
|
||||||
const cacheClient = await getCacheClient()
|
const cacheClient = await getCacheClient()
|
||||||
|
const countryKeys = Object.keys(citiesByCountry ?? {})
|
||||||
|
let cacheKey = `${lang}:locations`
|
||||||
|
|
||||||
|
if (countryKeys.length) {
|
||||||
|
cacheKey += `:${countryKeys.join(",")}`
|
||||||
|
}
|
||||||
|
|
||||||
return await cacheClient.cacheOrGet(
|
return await cacheClient.cacheOrGet(
|
||||||
`${lang}:locations`.toLowerCase(),
|
cacheKey.toLowerCase(),
|
||||||
async () => {
|
async () => {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
language: toApiLang(lang),
|
language: toApiLang(lang),
|
||||||
|
|||||||
Reference in New Issue
Block a user