I have a Django application that is designed to be used as a companion tool for sportsbooks or DFS sites. I am largely self-taught, so I have been adopting a more "go with what works" approach and then going back to revise my methods as I learn better ways to create the app.
I have several tables from scraped data in CSV format that I import into my DB with shell scripts. For example, one table is for starting lineups, and another is for player stats. I then have methods set up in my models.py to take that imported data and turn it into data that I want to use.
I found out quickly that trying to call a large group of objects and the values from their method functions was not at all efficient. I get the data I need via the methods because a lot of it is based on data from multiple tables (for example, I might want the start time of a game from the starting lineups table for a player object.)
The current solution that I have is to use Threading to run a function every few minutes to calculate the results of every method for the player objects, then storing that as a list of dictionaries in a variable, and importing that variable in the relevant views (rather than setting the variable to the objects themselves.) I'm sure there's a million ways this is a bad idea. I am still just learning.
I have heard some things about Celery and Redis, and think those could be used to do what I'm doing (but the right way, of course.) Am I on the right track? If so, are there any resources that you have found useful in using Celery/Redis?
Thank you for taking the time to help me out!
Aucun commentaire:
Enregistrer un commentaire