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
1=== modified file 'src/webcatalog/management/commands/import_ratings_stats.py'
2--- src/webcatalog/management/commands/import_ratings_stats.py 2012-06-06 16:38:11 +0000
3+++ src/webcatalog/management/commands/import_ratings_stats.py 2012-06-19 13:25:02 +0000
4@@ -50,6 +50,9 @@
5
6 stats = self.download_review_stats(distroseries)
7
8+ Application.objects.filter(distroseries=distroseries).update(
9+ wilson_score=-1)
10+
11 self.update_apps_with_stats(distroseries, stats)
12
13 self.update_last_import_timestamp(distroseries)
14
15=== modified file 'src/webcatalog/tests/test_commands.py'
16--- src/webcatalog/tests/test_commands.py 2012-06-14 16:18:12 +0000
17+++ src/webcatalog/tests/test_commands.py 2012-06-19 13:25:02 +0000
18@@ -776,6 +776,20 @@
19 result = command.update_apps_with_stats(app.distroseries, stats)
20 self.assertIsNone(result)
21
22+ def test_apps_with_no_reviews_end_up_with_minus_one(self):
23+ # Apps with no reviews should end up with wilson_score = -1
24+ natty = self.factory.make_distroseries(code_name='natty')
25+ app = self.factory.make_application(wilson_score=3.5,
26+ distroseries=natty)
27+ another_app = self.factory.make_application(wilson_score=3.5)
28+
29+ call_command('import_ratings_stats', 'natty')
30+
31+ retrieved = Application.objects.get(pk=app.id)
32+ self.assertEqual(-1, retrieved.wilson_score)
33+ retrieved = Application.objects.get(pk=another_app.id)
34+ self.assertEqual(3.5, retrieved.wilson_score)
35+
36
37 class ImportExhibitsTestCase(TestCaseWithFactory):
38

Subscribers

People subscribed via source and target branches