python - Google App Engine: how to tell sort location for a user value? -


in main model have total_value , sort value. when user enters value wish tell user order of total_value. how do this?

in other words, if total_values in database 5,8,10,25 , user enters total_value of 15 how tell him in 4th place?

thanks!

you need write query counts number of values smaller user's total_value. may slow if there many main entities. in case, may wish count first n values smaller, , stop (e.g., tell user ranked 1000+). query might this:

# rank of total_value compared existing total_values (up 1,000) rank = main.all().filter('total_value <', total_value).count(1000) + 1 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -