Expose bayesian rating average for add-ons in the API
This commit is contained in:
Родитель
d6c20f153a
Коммит
a14e999b9b
|
@ -138,6 +138,7 @@ This endpoint allows you to fetch a specific add-on by id, slug or guid.
|
|||
:>json object ratings: Object holding ratings summary information about the add-on.
|
||||
:>json int ratings.count: The number of user ratings for the add-on.
|
||||
:>json float ratings.average: The average user rating for the add-on.
|
||||
:>json float ratings.bayesian_average: The bayesian average user rating for the add-on.
|
||||
:>json string review_url: The URL to the review page for the add-on.
|
||||
:>json string slug: The add-on slug.
|
||||
:>json string status: The :ref:`add-on status <addon-detail-status>`.
|
||||
|
|
|
@ -265,6 +265,7 @@ class AddonSerializer(serializers.ModelSerializer):
|
|||
def get_ratings(self, obj):
|
||||
return {
|
||||
'average': obj.average_rating,
|
||||
'bayesian_average': obj.bayesian_rating,
|
||||
'count': obj.total_reviews,
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ class AddonSerializerOutputTestMixin(object):
|
|||
self.addon = addon_factory(
|
||||
average_daily_users=4242,
|
||||
average_rating=4.21,
|
||||
bayesian_rating=4.22,
|
||||
category=cat1,
|
||||
description=u'My Addôn description',
|
||||
file_kw={
|
||||
|
@ -199,6 +200,7 @@ class AddonSerializerOutputTestMixin(object):
|
|||
|
||||
assert result['ratings'] == {
|
||||
'average': self.addon.average_rating,
|
||||
'bayesian_average': self.addon.bayesian_rating,
|
||||
'count': self.addon.total_reviews,
|
||||
}
|
||||
assert result['public_stats'] == self.addon.public_stats
|
||||
|
|
Загрузка…
Ссылка в новой задаче