LAMaglan / PokeFightSimulator

A (simple) fight simulator between any two Pokemon using FastAPI with Jinja frontend
0 stars 0 forks source link

Refactor use of `get_pokemon` #65

Open LAMaglan opened 2 months ago

LAMaglan commented 2 months ago

"get_pokemon" is called separately for "/battle" and "/pokemon_stats" endpoint. How would I consolidate it?

Could make a global list that stores each Pokemon with all details that I fetch from? Or? Initial button for "use pokemon", and then only show "show stats" and "Battle!" ?

May "solve" stats_modifier here https://github.com/LAMaglan/PokeFightSimulator/issues/64

LAMaglan commented 2 weeks ago

Can maybe introduce caching, which means I can keep calling get_pokemon in multiple areas as is. BUT, caching with concurrent/asynchronous requests are not so trivial (at least in terms of "normal" caching)

LAMaglan commented 2 weeks ago

Can investigate fastapi-cache . But am not sure that it is worth it in the end (this is not a computationally heavy process), but can try

LAMaglan commented 2 weeks ago

Can cache asynchronous functions with fastapi-cache in combination with aioredis. However, would then need to run an instance of aioredis, which is not really worth it in this case.