I am making a django application. To calculate the rank of the feeds based on lines and comment, I am trying to use django-background-tasks. the function I am using in nodes models is:
p = self.likes+self.comments # popularity
t = (now()-self.date).total_seconds()/3600 # age_in_hrs
# last_activity =
n = self.admin_score
score = (p/pow((t+1), 1.2))*n
self.score = score
You should run
python manage.py process_tasks as described here. You can add it to crontab to execute periodically.
process_tasksusing crontab cause this command internally sleeps every 5 seconds (this value is configurable) and then again checks whether there is any task to run.
idof model inside it, fetch object by
iddo calculations and save your object.