~gary-lasker/software-center/trunk-reviews-tweaks

« back to all changes in this revision

Viewing changes to softwarecenter/view/appdetailsview_gtk.py

  • Committer: Michael Vogt
  • Date: 2011-01-26 19:57:54 UTC
  • mfrom: (1247.1.137 reviews)
  • Revision ID: michael.vogt@ubuntu.com-20110126195754-97bp4x75ukq3yzrc
merged from reviews

Show diffs side-by-side

added added

removed removed

Lines of Context:
1401
1401
        for review in reviews:
1402
1402
            self.reviews.add_review(review)
1403
1403
        # then update the stats (if needed). the caching can make them
1404
 
        # wrong
1405
 
        stats = ReviewStats(app)
1406
 
        stats.ratings_total = len(reviews)
1407
 
        if stats.ratings_total == 0:
1408
 
            stats.ratings_average = 0
1409
 
        else:
1410
 
            stats.ratings_average = sum([x.rating for x in reviews]) / float(stats.ratings_total)
1411
 
        self._update_review_stats_widget(stats)
 
1404
        # wrong, so if the reviews we have in the list are more than the
 
1405
        # stats we update manually
 
1406
        old_stats = self.review_loader.get_review_stats(self.app)
 
1407
        if old_stats is None or old_stats.ratings_total < len(reviews):
 
1408
            # generate new stats
 
1409
            stats = ReviewStats(app)
 
1410
            stats.ratings_total = len(reviews)
 
1411
            if stats.ratings_total == 0:
 
1412
                stats.ratings_average = 0
 
1413
            else:
 
1414
                stats.ratings_average = sum([x.rating for x in reviews]) / float(stats.ratings_total)
 
1415
            # update UI
 
1416
            self._update_review_stats_widget(stats)
 
1417
            # update global stats cache as well
 
1418
            self.review_loader.REVIEW_STATS_CACHE[app] = stats
1412
1419
        self.reviews.finished()
1413
1420
 
1414
1421
    def _on_allocate(self, widget, allocation):