Add locations to todo items and automate Gitea deploy
Some checks failed
Redeploy Docker Compose / redeploy (push) Failing after 2s
Some checks failed
Redeploy Docker Compose / redeploy (push) Failing after 2s
This commit is contained in:
@@ -15,10 +15,38 @@ interface PopularResponse {
|
||||
|
||||
let catalogPromise: Promise<CatalogResponse> | null = null;
|
||||
|
||||
function normalizeKnownLocations(value: unknown): string[] | undefined {
|
||||
if (!Array.isArray(value)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = value
|
||||
.map((location) => (typeof location === 'string' ? location.trim() : ''))
|
||||
.filter((location) => Boolean(location));
|
||||
|
||||
return normalized.length > 0 ? normalized : undefined;
|
||||
}
|
||||
|
||||
function normalizeCatalog(payload: CatalogResponse): CatalogResponse {
|
||||
const normalizedItems = payload.items.map((item) => ({
|
||||
...item,
|
||||
knownLocations: normalizeKnownLocations(item.knownLocations),
|
||||
}));
|
||||
|
||||
const normalizedUpgrades = payload.upgrades.map((upgrade) => {
|
||||
if (Array.isArray(upgrade.levels)) {
|
||||
return upgrade;
|
||||
return {
|
||||
...upgrade,
|
||||
levels: upgrade.levels.map((level) => ({
|
||||
...level,
|
||||
salvage: Array.isArray(level.salvage)
|
||||
? level.salvage.map((salvageItem) => ({
|
||||
...salvageItem,
|
||||
knownLocations: normalizeKnownLocations(salvageItem.knownLocations),
|
||||
}))
|
||||
: [],
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
const legacyUpgrade = upgrade as UpgradeSearchResult & { salvage?: UpgradeSearchResult['levels'][number]['salvage'] };
|
||||
@@ -26,12 +54,21 @@ function normalizeCatalog(payload: CatalogResponse): CatalogResponse {
|
||||
|
||||
return {
|
||||
...upgrade,
|
||||
levels: [{ level: 1, salvage }],
|
||||
levels: [
|
||||
{
|
||||
level: 1,
|
||||
salvage: salvage.map((salvageItem) => ({
|
||||
...salvageItem,
|
||||
knownLocations: normalizeKnownLocations(salvageItem.knownLocations),
|
||||
})),
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
...payload,
|
||||
items: normalizedItems,
|
||||
upgrades: normalizedUpgrades,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user