Commit 687e2c9a authored by nanahira's avatar nanahira

remove unnecessary fields

parent a688b89d
Pipeline #24717 passed with stages
in 2 minutes and 50 seconds
......@@ -344,15 +344,6 @@ async function formatCard(data: YGOProCardLike): Promise<YGOProCard> {
};
Object.assign(result, history);
if (process.env.FIELDS) {
const fields = new Set(process.env.FIELDS.split(','));
// keep only the fields specified
for (const key of Object.keys(result)) {
if (!fields.has(key)) {
delete result[key];
}
}
}
return result as YGOProCard;
}
......@@ -368,8 +359,18 @@ async function main() {
);
const formattedCards = await Promise.all(cards.map(formatCard));
// order by createTime desc
if (formattedCards[0].createTime != null) {
formattedCards.sort((a, b) => b.createTime - a.createTime);
// remove unnecessary fields
if (process.env.FIELDS) {
const fields = new Set(process.env.FIELDS.split(','));
// keep only the fields specified
for (const card of formattedCards) {
for (const key of Object.keys(card)) {
if (!fields.has(key)) {
delete card[key];
}
}
}
}
console.log(JSON.stringify(formattedCards, null, 2));
process.exit(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment