Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion open-api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2340,6 +2340,13 @@
"type": "string"
},
"description": "The checkpoint encounter name for each raid activityId, used in lowman tag labels"
},
"versionCheckpointNames": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "The checkpoint encounter name for each Pantheon versionId, used in lowman tag labels"
}
},
"required": [
Expand All @@ -2361,7 +2368,8 @@
"feats",
"splashUrls",
"versionSplashUrls",
"checkpointNames"
"checkpointNames",
"versionCheckpointNames"
],
"additionalProperties": false
},
Expand Down
19 changes: 16 additions & 3 deletions src/routes/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { zFeatDefinition } from "@/schema/components/FeatDefinition"
import { zImageContentData } from "@/schema/components/ImageContentData"
import { zVersionDefinition } from "@/schema/components/VersionDefinition"
import { zNaturalNumber, zNumericalRecordKey } from "@/schema/output"
import { getCheckpointNamesForRaids } from "@/services/manifest/checkpoint-names"
import {
getCheckpointNamesForRaids,
getVersionCheckpointNames
} from "@/services/manifest/checkpoint-names"
import {
listActivityDefinitions,
listFeatDefinitions,
Expand Down Expand Up @@ -127,6 +130,10 @@ export const manifestRoute = new RaidHubRoute({
checkpointNames: z.record(zNumericalRecordKey(), z.string()).openapi({
description:
"The checkpoint encounter name for each raid activityId, used in lowman tag labels"
}),
versionCheckpointNames: z.record(zNumericalRecordKey(), z.string()).openapi({
description:
"The checkpoint encounter name for each Pantheon versionId, used in lowman tag labels"
})
})
.strict()
Expand Down Expand Up @@ -172,6 +179,8 @@ export const manifestRoute = new RaidHubRoute({
}
})
.map(a => a.id)
const versionDefinitionsById = Object.fromEntries(versions.map(data => [data.id, data]))
const pantheonVersionIdsAll = [...pantheonVersionIds, ...pantheonSunsetVersionIds]

return RaidHubRoute.ok({
hashes: Object.fromEntries(
Expand All @@ -184,7 +193,7 @@ export const manifestRoute = new RaidHubRoute({
])
),
activityDefinitions: Object.fromEntries(activities.map(data => [data.id, data])),
versionDefinitions: Object.fromEntries(versions.map(data => [data.id, data])),
versionDefinitions: versionDefinitionsById,
listedRaidIds,
sunsetRaidIds: raids.filter(a => a.isSunset).map(a => a.id),
prestigeRaidIds: [
Expand All @@ -206,7 +215,11 @@ export const manifestRoute = new RaidHubRoute({
feats: feats,
splashUrls: splashUrls,
versionSplashUrls: versionSplashUrls,
checkpointNames: getCheckpointNamesForRaids(listedRaidIds)
checkpointNames: getCheckpointNamesForRaids(listedRaidIds),
versionCheckpointNames: getVersionCheckpointNames(
pantheonVersionIdsAll,
versionDefinitionsById
)
})
}
})
21 changes: 21 additions & 0 deletions src/services/manifest/checkpoint-names.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect, test } from "bun:test"
import { getPantheonCheckpointName, getVersionCheckpointNames } from "./checkpoint-names"

test("getPantheonCheckpointName drops trailing adjective", () => {
expect(getPantheonCheckpointName("Oryx Exalted")).toBe("Oryx")
expect(getPantheonCheckpointName("Atraks Sovereign")).toBe("Atraks")
expect(getPantheonCheckpointName("Morgeth Surpassing")).toBe("Morgeth")
expect(getPantheonCheckpointName("Insurrection Prime Revolutionary")).toBe("Insurrection Prime")
})

test("getVersionCheckpointNames maps pantheon version ids", () => {
expect(
getVersionCheckpointNames([129, 134], {
129: { name: "Oryx Exalted" },
134: { name: "Insurrection Prime Revolutionary" }
})
).toEqual({
129: "Oryx",
134: "Insurrection Prime"
})
})
29 changes: 29 additions & 0 deletions src/services/manifest/checkpoint-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,32 @@
.map(id => [id, CHECKPOINT_NAMES[id]] as const)
.filter((entry): entry is [number, string] => entry[1] != null)
)

/** Pantheon checkpoint labels drop the trailing difficulty adjective, e.g. "Oryx Exalted" -> "Oryx". */
export const getPantheonCheckpointName = (versionName: string): string | null => {
const parts = versionName.trim().split(/\s+/).filter(Boolean)
if (parts.length === 0) {
return null

Check warning on line 32 in src/services/manifest/checkpoint-names.ts

View workflow job for this annotation

GitHub Actions / test

32 line is not covered with tests
}
if (parts.length === 1) {
return parts[0]
}
return parts.slice(0, -1).join(" ")
}

export const getVersionCheckpointNames = (
versionIds: readonly number[],
versionDefinitions: Readonly<Record<number, { name: string }>>
) =>
Object.fromEntries(
versionIds
.map(id => {
const versionName = versionDefinitions[id]?.name
if (!versionName) {
return null

Check warning on line 49 in src/services/manifest/checkpoint-names.ts

View workflow job for this annotation

GitHub Actions / test

49 line is not covered with tests
}
const checkpointName = getPantheonCheckpointName(versionName)
return checkpointName ? ([id, checkpointName] as const) : null
})
.filter((entry): entry is [number, string] => entry != null)
)
Loading