I'm pretty new to databases and googles app engine, and I'm having a
hard time getting saved data and averaging it. So basically we have a
comments and ratings system where they can type comments and add
ratings, but I can't figure out how to get all the ratings, and
average them. I just simply do
Hi Wilson,
You outlined the pattern to do this yourself. Fetch the entities
you want to average, add up the ratings, then divide by the number of
ratings. There are several ways to do this, in Python one very easy
to follow method might look like:
# Get the ratings entities.
ratings_en
Whoops, in the second method there is a typo. count() should be len():
average_rating = float(sum(ratings)) / len(ratings)
On Thu, May 5, 2011 at 00:23, Robert Kluin wrote:
> Hi Wilson,
> You outlined the pattern to do this yourself. Fetch the entities
> you want to average, add up th
Wow, I also forgot to include a few helpful links.
The Datastore:
http://code.google.com/appengine/docs/python/datastore/
And, it sounds like you might want to explore some general Python resources too:
http://python.org/doc/
Robert
On Thu, May 5, 2011 at 00:23, Robert Kluin wrote:
>