PennyDreadfulMTG / Penny-Dreadful-Tools

A suite of tools for the Penny Dreadful MTGO community
https://pennydreadfulmagic.com
MIT License
40 stars 28 forks source link

https://pennydreadfulmagic.com/decks/193372/ shows as Not Legal but it is legal #10512

Open vorpal-buildbot opened 2 years ago

vorpal-buildbot commented 2 years ago

Reported on Discord by bakert#2193

bakert commented 1 year ago

This also affects deck with id=1 and probably zillions of others.

You don't get your deck_cache.legal_formats updated unless we call deck.prime_cache. And we stopped doing that as as part of maintenance.reprime_cache way back in 2020 in 949aaad because it was taking 30 minutes.

Huh.

bakert commented 1 year ago

This is what we used to do:

-    ds = deck.load_decks()
-    for d in ds:
-        redis.clear(f'decksite:deck:{d.id}')
-        deck.prime_cache(d)
-        redis.clear(f'decksite:deck:{d.id}')

Loading the decks on local takes over 30s.

Running through the whole process deck-by-deck took somewhere in the 25-40 minutes range (I got distracted!)

Maybe we should reprime some small slice of decks every day in a daily or something?

bakert commented 1 year ago

Running it for 1/50th of decks took just a few seconds.


>>> ds = deck.load_decks('d.id %% 50 = 0')
>>> len(ds)
3513
>>> for d in ds:
...     redis.clear(f'decksite:deck:{d.id}')
...     deck.prime_cache(d)
...     redis.clear(f'decksite:deck:{d.id}')
... 
``
bakert commented 1 year ago

Maybe add a cached_date column to deck_cache and refresh the 500 or 1000 least-recently-refreshed as a daily task?

This really only needs to be done once per season so it could be part of rotation. But that's intense enough already.

bakert commented 1 year ago

As well as setting the legal formats for the deck this would rectify any problems with season_id not matching created_date and apply any advances in deck name sanitization. It also updates deck colors and colored symbols but that code hasn't changed in a long time. Not a whole lot but probably worth doing. Saying "Not Legal" on a page for a deck that is currently legal does kinda suck even if it has taken three years to notice more than once or twice :)

bakert commented 5 months ago

I ran it on 1/30th of decks in prod in about 95s. 1/90th took 32s. (Of course these numbers would grow.)

32s is a bit longer than I want but not the end of the world. 90 days though is a fairly long schedule if we actually care about any of these things.

Hm.