Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: fail at getting uuid more gracefully #1702

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
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
12 changes: 8 additions & 4 deletions scripts/download_booster_rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ async function fetch() {
acc[code] = {
balance_colors,
totalWeight,
cards: Object.entries(cards).reduce((acc, [cardCode, weigth]) => {
cards: Object.entries(cards).reduce((acc, [cardCode, weight]) => {
const uuid = getUuid(cardCode);
acc[uuid] = weigth;
if (uuid) acc[uuid] = weight;
return acc;
},{}),
cardsByColor: Object.entries(cards).reduce((acc, [cardCode]) => {
Expand Down Expand Up @@ -77,8 +77,12 @@ const getCard = (cardCode) => {

const getUuid = (cardCode) => {
const [setCode, cardNumber] = cardCode.split(":");
const { cardsByNumber } = getSet(setCode.toUpperCase());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line here was the gotcha - destructuring undefined was causing an error to be thrown in CI

I don't know why the set would not be found, maybe that's an error which should throw, as it shows your data is somehow really wrong.

return cardsByNumber[cardNumber] || cardsByNumber[parseInt(cardNumber)] || cardsByNumber[cardNumber.toLowerCase()];
const set = getSet(setCode.toUpperCase());
if (!set) {
logger.warn("unknown setCode: " + setCode.toUpperCase());
return;
}
return set.cardsByNumber[cardNumber] || set.cardsByNumber[parseInt(cardNumber)] || set.cardsByNumber[cardNumber.toLowerCase()];
};

module.exports = fetch;
Expand Down