Open vorpal-buildbot opened 2 years 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.
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?
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}')
...
``
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.
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 :)
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.
Reported on Discord by bakert#2193