mirror of
https://github.com/tcgdex/compiler.git
synced 2025-07-03 04:09:19 +00:00
Automatically calculate the set.cardCount.total field (#11)
Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net>
This commit is contained in:
@ -65,6 +65,7 @@ export async function getSetPictures(set: Set, lang: SupportedLanguages): Promis
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function setToSetSimple(set: Set, lang: SupportedLanguages): Promise<SetResume> {
|
export async function setToSetSimple(set: Set, lang: SupportedLanguages): Promise<SetResume> {
|
||||||
|
const cards = await getCards(lang, set)
|
||||||
const pics = await getSetPictures(set, lang)
|
const pics = await getSetPictures(set, lang)
|
||||||
return {
|
return {
|
||||||
id: set.id,
|
id: set.id,
|
||||||
@ -72,7 +73,7 @@ export async function setToSetSimple(set: Set, lang: SupportedLanguages): Promis
|
|||||||
symbol: pics[1],
|
symbol: pics[1],
|
||||||
name: set.name[lang] as string,
|
name: set.name[lang] as string,
|
||||||
cardCount: {
|
cardCount: {
|
||||||
total: set.cardCount.total,
|
total: Math.max(set.cardCount.official, cards.length),
|
||||||
official: set.cardCount.official
|
official: set.cardCount.official
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ export async function setToSetSingle(set: Set, lang: SupportedLanguages): Promis
|
|||||||
},
|
},
|
||||||
tcgOnline: set.tcgOnline,
|
tcgOnline: set.tcgOnline,
|
||||||
cardCount: {
|
cardCount: {
|
||||||
total: set.cardCount.total,
|
total: Math.max(set.cardCount.official, cards.length),
|
||||||
official: set.cardCount.official,
|
official: set.cardCount.official,
|
||||||
normal: cards.reduce((count, card) => count + (card[1].variants?.normal ?? set.variants?.normal ? 1 : 0), 0),
|
normal: cards.reduce((count, card) => count + (card[1].variants?.normal ?? set.variants?.normal ? 1 : 0), 0),
|
||||||
reverse: cards.reduce((count, card) => count + (card[1].variants?.reverse ?? set.variants?.reverse ? 1 : 0), 0),
|
reverse: cards.reduce((count, card) => count + (card[1].variants?.reverse ?? set.variants?.reverse ? 1 : 0), 0),
|
||||||
|
Reference in New Issue
Block a user