In my app, users earn a score and their details get stored in the datastore. When the user logs in, I want to show their rank among all users(basically how far away from the top score they are). So my solution was to sort the users' profiles in descending order the put the index+1 to the Profile model and run it in a cron.
However the cron fails. Any help or advise on a better way would be appreciated:
from google.appengine.ext import db
def universal_rank(self):
users = Profile.all().filter('leaderboard =', l.key()).order('-score')
rank = 0
for user in users:
rank = rank + 1
user.rank = rank
db.put(users)
I'm using webapp2