Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit 9d69ae8

Browse files
author
Rob Hudson
committed
Filter out installed apps from recommendations list (bug 1109126)
The recommendation engine should do this but may not in some cases.
1 parent e36a7e9 commit 9d69ae8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

mkt/recommendations/tests/test_views.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,12 @@ def test_no_filter_if_no_dev(self):
152152
eq_(len(objects), 2)
153153
self.assertSetEqual([a['id'] for a in objects],
154154
[a.pk for a in self.apps])
155+
156+
def test_no_installed_apps(self):
157+
self.profile.installed_set.create(addon=self.apps[0])
158+
159+
res = self.client.get(self.url)
160+
eq_(res.status_code, 200)
161+
objects = res.json['objects']
162+
eq_(len(objects), 1)
163+
self.assertSetEqual([a['id'] for a in objects], [self.apps[1].pk])

mkt/recommendations/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ def list(self, request, *args, **kwargs):
5757
# Fall back to a popularity search.
5858
return self._popular()
5959

60+
# Get list of installed apps and remove from app_ids.
61+
installed = list(
62+
request.user.installed_set.values_list('addon_id', flat=True))
63+
app_ids = filter(lambda a: a not in installed, app_ids)
64+
6065
device = get_device_id(request)
6166
filters = {'device': device} if device else None
6267

0 commit comments

Comments
 (0)