mtgtools icon indicating copy to clipboard operation
mtgtools copied to clipboard

Add filtering for incomplete sets when updating

Open Julian-Brendel opened this issue 4 years ago • 2 comments

Every call to scryfall_update was triggering each page for each set to be re-downloaded, resulting in roughly 750 requests. By restricting the update to incomplete sets, the number of requests made can be cut down dramatically.

Adds

  • Filtering for incomplete sets before creating card_page_uris for scryfall_update

Julian-Brendel avatar Jun 27 '20 17:06 Julian-Brendel

I can confirm that this works (see shorter update time)! (no code review though...)

Before:

(.python3_virtual_environment) username@ThinkPad-X1 ~/Projects/mtg-scanner $ python test_mtgtools.py 
Attempting to update all the data...
querying Scryfall API...
Found a total of 0 new sets and 57 new cards
Fetching new cards and updating old.
-----------------------------------------------------------------------------------------------
The Scryfall database is now up to date! 
Elapsed time: 0:02:01[Werebear (ema), Werebear (td0), Werebear (wc02), Werebear (ody)]
(.python3_virtual_environment) username@ThinkPad-X1 ~/Projects/mtg-scanner $ ]

After:

(.python3_virtual_environment) username@ThinkPad-X1 ~/Projects/mtg-scanner $ python test_mtgtools.py 
Attempting to update all the data...
querying Scryfall API...
Found a total of 0 new sets and 57 new cards
Fetching new cards and updating old.
-----------------------------------------------------------------------------------------------
The Scryfall database is now up to date! 
Elapsed time: 0:00:27[Werebear (ema), Werebear (td0), Werebear (wc02), Werebear (ody)]

KUGA2 avatar Dec 20 '20 15:12 KUGA2

I think this is generally good improvement. I think I used to have another function which only checked for new cards but there was some very specific problem with it, I cant remember what. I just then scrapped the partial update and left the one that updated everything. Note, that the updater not only saves the new cards but also rewrites the possible changes to the old ones.

I think the best improvement right now would be to instead download and parse the bulk data files Scryfall offers instead of the requests. The bulk data probably contains some extra/useless stuff for most purposes but the database can be separated for example in collections like

  • All cards
  • Cards in boosters
  • Unique artwork
  • etc

EskoSalaka avatar Jan 14 '21 19:01 EskoSalaka