Merge lp:~elachuni/ubuntu-webcatalog/noreviews-last into lp:ubuntu-webcatalog

Proposed by Anthony Lenton
Status: Merged
Approved by: Łukasz Czyżykowski
Approved revision: 144
Merged at revision: 144
Proposed branch: lp:~elachuni/ubuntu-webcatalog/noreviews-last
Merge into: lp:ubuntu-webcatalog
Diff against target: 37 lines (+17/-0)
2 files modified
src/webcatalog/management/commands/import_ratings_stats.py (+3/-0)
src/webcatalog/tests/test_commands.py (+14/-0)
To merge this branch: bzr merge lp:~elachuni/ubuntu-webcatalog/noreviews-last
Reviewer Review Type Date Requested Status
Canonical Consumer Applications Hackers Pending
Review via email: mp+111012@code.launchpad.net

Commit message

Sent apps with no reviews to the end of all app listings.

Description of the change

This branch sends apps with no reviews to the end of all app listings (department overviews and search results) by assigning wilson_score to all apps before starting to import ratings data.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/webcatalog/management/commands/import_ratings_stats.py'
--- src/webcatalog/management/commands/import_ratings_stats.py 2012-06-06 16:38:11 +0000
+++ src/webcatalog/management/commands/import_ratings_stats.py 2012-06-19 13:25:02 +0000
@@ -50,6 +50,9 @@
5050
51 stats = self.download_review_stats(distroseries)51 stats = self.download_review_stats(distroseries)
5252
53 Application.objects.filter(distroseries=distroseries).update(
54 wilson_score=-1)
55
53 self.update_apps_with_stats(distroseries, stats)56 self.update_apps_with_stats(distroseries, stats)
5457
55 self.update_last_import_timestamp(distroseries)58 self.update_last_import_timestamp(distroseries)
5659
=== modified file 'src/webcatalog/tests/test_commands.py'
--- src/webcatalog/tests/test_commands.py 2012-06-14 16:18:12 +0000
+++ src/webcatalog/tests/test_commands.py 2012-06-19 13:25:02 +0000
@@ -776,6 +776,20 @@
776 result = command.update_apps_with_stats(app.distroseries, stats)776 result = command.update_apps_with_stats(app.distroseries, stats)
777 self.assertIsNone(result)777 self.assertIsNone(result)
778778
779 def test_apps_with_no_reviews_end_up_with_minus_one(self):
780 # Apps with no reviews should end up with wilson_score = -1
781 natty = self.factory.make_distroseries(code_name='natty')
782 app = self.factory.make_application(wilson_score=3.5,
783 distroseries=natty)
784 another_app = self.factory.make_application(wilson_score=3.5)
785
786 call_command('import_ratings_stats', 'natty')
787
788 retrieved = Application.objects.get(pk=app.id)
789 self.assertEqual(-1, retrieved.wilson_score)
790 retrieved = Application.objects.get(pk=another_app.id)
791 self.assertEqual(3.5, retrieved.wilson_score)
792
779793
780class ImportExhibitsTestCase(TestCaseWithFactory):794class ImportExhibitsTestCase(TestCaseWithFactory):
781795

Subscribers

People subscribed via source and target branches