Closed rinoma closed 5 years ago
Here's my thought: We always get the giveaway url to do the is skippable test. What if we store that as currentGiveawayUrl
in the giveaways.js file, and we use it everywhere? Then it will always be saving the /ga/p/
version of the url even if you win? See my changes here:
https://github.com/jpchip/giveaway-grabber/blob/log-price-check/src/giveaways.js
The way you did it looks fine to me.
When a giveaway is already entered, the URL is saved in the DB. However, the url format of a giveaway that has already been won is different: When the url is saved it contains the string
/ga/won/
. When searching the db, it is searched with/ga/p/
and it isn't found. The winning url is saved again in the db. An error is returned because the url is not unique.