I am building a Travian clone for learning purposes using FastAPI for the backend. I want to update my current logged user tables whenever they are making a new request (such as loading a new page) unlike updating tables every x seconds.
Since I am using FastAPI, I found that a middleware could be a good option to update tables for every new HTTP request. However, there are a lot of tables that may be updated:
- Resources (always)
- Ingoing attacks
- Outgoing attacks
- Building / Upgrading buildings
- Building / Upgrading troops ...
What would be the best approach to update my tables for every new HTTP request? Updating every table may be a bit more time-consuming but probably easier to manage.
This is related to question 1, but since I chose to update my tables on every call, I must store somewhere a timestamp of a column
last_updated_timestamp
in order to calculate the new value. Should I create this column for every table that is re-calculated or should I hold a singlelast_updated_timestamp
value for every table?