diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2014-02-02 09:29:43 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2014-02-02 09:29:43 (GMT) |
commit | 726ac1d66321ee7ac6b4cc7eff17001b5aeb6c5e (patch) | |
tree | 76416a704a112f70b9f8ce73833054ddd55a680f /sugar_network/node/stats_node.py | |
parent | de24419942178dbf17acd9311d0c0edf8d49be17 (diff) |
Smplify raiting resource property
Diffstat (limited to 'sugar_network/node/stats_node.py')
-rw-r--r-- | sugar_network/node/stats_node.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sugar_network/node/stats_node.py b/sugar_network/node/stats_node.py index ed2c0bd..d37819b 100644 --- a/sugar_network/node/stats_node.py +++ b/sugar_network/node/stats_node.py @@ -118,7 +118,7 @@ class Sniffer(object): for resource, stats in self._stats.items(): old = { 'downloads': 0, - 'reviews': (0, 0), + 'rating': (0, 0), } directory = self._volume[resource] for guid, new in stats.objects.items(): @@ -131,12 +131,11 @@ class Sniffer(object): patch = {} if 'downloads' in new: patch['downloads'] = new['downloads'] + old['downloads'] - if 'reviews' in new: - reviews, rating = old['reviews'] - reviews += new['reviews'] + if 'votes' in new: + votes, rating = old['rating'] + votes += new['votes'] rating += new['rating'] - patch['reviews'] = [reviews, rating] - patch['rating'] = int(round(float(rating) / reviews)) + patch['rating'] = [votes, rating] directory.update(guid, patch) stats.objects.clear() @@ -296,7 +295,7 @@ class _PostStats(_ResourceStats): stats = self._stats['post'] guid = request.content['topic'] if stats: - stats.inc(guid, 'reviews') + stats.inc(guid, 'votes') stats.inc(guid, 'rating', request.content.get('vote') or 0) elif request.method == 'GET' and request.prop == 'data': |