Merged in chore/remove-unused-code (pull request #2229)

Remove unused code

* Remove unused scandic-web files

* Remove unused exports


Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-05-30 12:41:18 +00:00
parent 44e648e758
commit 7e97b74c18
76 changed files with 1 additions and 3210 deletions

View File

@@ -1,112 +1,16 @@
import { GetHotelPageRefs } from "@/lib/graphql/Query/HotelPage/HotelPage.graphql"
import { GetHotelPageCount } from "@/lib/graphql/Query/HotelPage/HotelPageCount.graphql"
import { GetHotelPageUrls } from "@/lib/graphql/Query/HotelPage/HotelPageUrl.graphql"
import { request } from "@/lib/graphql/request"
import { notFound } from "@/server/errors/trpc"
import { createCounter } from "@/server/telemetry"
import {
generateRefsResponseTag,
generateTag,
generateTagsFromSystem,
} from "@/utils/generateTag"
import { batchedHotelPageUrlsSchema, hotelPageCountSchema } from "./output"
import {
batchedHotelPageUrlsSchema,
hotelPageCountSchema,
hotelPageRefsSchema,
} from "./output"
import { HotelPageEnum } from "@/types/enums/hotelPage"
import type { System } from "@/types/requests/system"
import type {
GetHotelPageCountData,
GetHotelPageRefsSchema,
GetHotelPageUrlsData,
HotelPageRefs,
} from "@/types/trpc/routers/contentstack/hotelPage"
import type { Lang } from "@/constants/languages"
export async function fetchHotelPageRefs(lang: Lang, uid: string) {
const getHotelPageRefsCounter = createCounter(
"trpc.contentstack",
"hotelPage.get.refs"
)
const metricsGetHotelPageRefs = getHotelPageRefsCounter.init({ lang, uid })
metricsGetHotelPageRefs.start()
const refsResponse = await request<GetHotelPageRefsSchema>(
GetHotelPageRefs,
{ locale: lang, uid },
{
key: generateRefsResponseTag(lang, uid),
ttl: "max",
}
)
if (!refsResponse.data) {
const notFoundError = notFound(refsResponse)
metricsGetHotelPageRefs.noDataError()
throw notFoundError
}
return refsResponse.data
}
export function validateHotelPageRefs(
data: GetHotelPageRefsSchema,
lang: Lang,
uid: string
) {
const getHotelPageRefsCounter = createCounter(
"trpc.contentstack",
"hotelPage.get.refs"
)
const metricsGetHotelPageRefs = getHotelPageRefsCounter.init({ lang, uid })
const validatedData = hotelPageRefsSchema.safeParse(data)
if (!validatedData.success) {
metricsGetHotelPageRefs.validationError(validatedData.error)
return null
}
metricsGetHotelPageRefs.success()
return validatedData.data
}
export function generatePageTags(
validatedData: HotelPageRefs,
lang: Lang
): string[] {
const connections = getConnections(validatedData)
return [
generateTagsFromSystem(lang, connections),
generateTag(lang, validatedData.hotel_page.system.uid),
].flat()
}
export function getConnections({ hotel_page }: HotelPageRefs) {
const connections: System["system"][] = [hotel_page.system]
if (hotel_page.content) {
hotel_page.content.forEach((block) => {
switch (block.__typename) {
case HotelPageEnum.ContentStack.blocks.ActivitiesCard: {
if (block.upcoming_activities_card.length) {
connections.push(...block.upcoming_activities_card)
}
break
}
}
if (hotel_page.faq) {
connections.push(...hotel_page.faq)
}
})
}
return connections
}
export async function getHotelPageCount(lang: Lang) {
const getHotelPageCountCounter = createCounter(
"trpc.contentstack",