nullromo / mtg-spoiler-notifier

Detects new cards uploaded to scryfall.com and sends e-mail and Discord updates.
MIT License
2 stars 0 forks source link

Merge CI artifact correctly #4

Closed nullromo closed 5 months ago

nullromo commented 5 months ago

Current Behavior

The latest CI artifact is set to the result of the card list Scryfall API call. This means that if the card list from run 1 is [a, b], then cards a and b will get sent out. If the list from run N is [a, b, c], then card c will get sent out. Then if the card list from run N + 1 is somehow [a, b], then the latest artifact going into run N + 2 is [a, b]. This will lead to an eventual run N + M in which item c comes back and card c gets sent out again. It is not good to have a card get sent out twice.

Solution

Instead of saving the artifact as the list of the result of the all cards list, it should be the old cards list merged in with the new cards. Using the example above, if the result from run N is [a, b, c] and run N + 1 detects [a, b], then run N + 1 should emit removeDuplicates([...[a, b, c], ...[a, b]]).