get_product_rating slow

Create issue
Issue #969 resolved
Alex Robbins created an issue

The get_product_rating function in productratings/ looks like it was coded before aggregates, and possibly before select_related. It was generating a query for every comment on a product, and then calculating the average in python.

The attached diff uses aggregates to accomplish the same job in two queries, not matter how many comments exist. Also, the averaging is done in the db so there isn't a for loop afterward.

Comments (2)

  1. Log in to comment