Merge lp:~gary-lasker/software-center/recommender-feedback-viewed into lp:software-center

Proposed by Gary Lasker
Status: Merged
Merged at revision: 3165
Proposed branch: lp:~gary-lasker/software-center/recommender-feedback-viewed
Merge into: lp:software-center
Diff against target: 84 lines (+40/-2)
3 files modified
softwarecenter/enums.py (+1/-0)
softwarecenter/ui/gtk3/widgets/recommendations.py (+13/-2)
tests/gtk3/test_catview.py (+26/-0)
To merge this branch: bzr merge lp:~gary-lasker/software-center/recommender-feedback-viewed
Reviewer Review Type Date Requested Status
software-store-developers Pending
Review via email: mp+123670@code.launchpad.net

Commit message

* lp:~gary-lasker/software-center/recommender-feedback-viewed:
    - augment the recommendations feedback to indicate when a
      recommended item has been selected (LP: #1044107)

Description of the change

This branch augments the implicit recommender feature (bug 1044107) by making a call to the recommender service when a recommended item is viewed, rather than only after a successful install. This was added in response to a request from the server team. A unit test for the new call is included.

Many thanks for your review!

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, that looks good and its great that this could get added quickly (and I like the test!).

Unfortunately the test fails for me with:
$ PYTHONPATH=. python tests/gtk3/test_catview.py RecommendationsTestCase
...
======================================================================
ERROR: test_implicit_recommender_feedback_on_item_viewed (__main__.RecommendationsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/gtk3/test_catview.py", line 276, in test_implicit_recommender_feedback_on_item_viewed
    self._populate_recommended_for_you_panel()
AttributeError: 'RecommendationsTestCase' object has no attribute '_populate_recommended_for_you_panel'

======================================================================
FAIL: test_recommended_for_you_spinner_display (__main__.RecommendationsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/gtk3/test_catview.py", line 162, in test_recommended_for_you_spinner_display
    self.rec_panel.recommended_for_you_content.get_property("visible"))
AssertionError: False is not true

----------------------------------------------------------------------
Ran 10 tests in 20.199s

One of the failures is probably releated to the lp:~gary-lasker/software-center/recommender-test-fix that I merged earlier and trivial to update. I have no idea about the other one, but it could be something that
is simply a side effect of the first.

When this branch needs to get touched anyway it would be nice to add a small comment to "on_application_activated" like "# send viewed items to the recommender in addition to installed ones" or similar. For a moment I was confused when looking at the code as it looks similar to the part in _on_transaction_finished (i.e. the difference of the two blocks is only visible when looking at the last part that has either "RecommenderFeedbackActions.INSTALLED" or RecommenderFeedbackActions.VIEWED). Or maybe extracting it into a common function?

3159. By Gary Lasker

merge trunk

3160. By Gary Lasker

fix the new unit test to conform to the updates that were contained in my other (not-yet-merged-at-the-time) branch lp:~gary-lasker/software-center/recommender-test-fix

3161. By Gary Lasker

add some comments as requested in the MP

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Hi Michael, thanks as always for your review. Indeed, the first failure is a trivial case related to my other branch lp:~gary-lasker/software-center/recommender-test-fix. That branch contained a change to a method name (to make its purpose more clear), and as it had not yet been merged to trunk yet my new test still used the previous method name. I merged trunk and fixed this line and the test works again now.

I also added comments to both places where I make implicit_feedback calls to the recommender service.

Finally, the second failure above (test_recommended_for_you_spinner_display) is unrelated to any changes that I have made, and as I mentioned in https://code.launchpad.net/~gary-lasker/software-center/recommender-test-fix/+merge/123669, I have seen this one intermittently for a while now). I think it is simply due to a race issue in the unit test as I see no issues at all in the working code. I'll take a look at that test and see if I can make it reliable, but that work in another branch!

I think this one is ready for review again. Thanks again!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/enums.py'
--- softwarecenter/enums.py 2012-08-29 22:56:22 +0000
+++ softwarecenter/enums.py 2012-09-11 14:47:19 +0000
@@ -284,6 +284,7 @@
284284
285# action values for recommendations feedback285# action values for recommendations feedback
286class RecommenderFeedbackActions:286class RecommenderFeedbackActions:
287 VIEWED = "viewed"
287 INSTALLED = "installed"288 INSTALLED = "installed"
288289
289# mouse event codes for back/forward buttons290# mouse event codes for back/forward buttons
290291
=== modified file 'softwarecenter/ui/gtk3/widgets/recommendations.py'
--- softwarecenter/ui/gtk3/widgets/recommendations.py 2012-09-05 20:34:14 +0000
+++ softwarecenter/ui/gtk3/widgets/recommendations.py 2012-09-11 14:47:19 +0000
@@ -72,10 +72,19 @@
7272
73 def _on_application_activated(self, tile, app):73 def _on_application_activated(self, tile, app):
74 self.emit("application-activated", app)74 self.emit("application-activated", app)
75 # we only track installed items if the user has opted-in to the75 # we only report on items if the user has opted-in to the
76 # recommendations service76 # recommendations service
77 if self.recommender_agent.is_opted_in():77 if self.recommender_agent.is_opted_in():
78 self.recommended_apps_viewed.add(app.pkgname)78 self.recommended_apps_viewed.add(app.pkgname)
79 if network_state_is_connected():
80 # let the recommendations service know that a
81 # recommended item has been viewed (if it is
82 # subsequently installed we will send an additional
83 # signal to indicate that, in on_transaction_finished)
84 # (there is no need to monitor for an error, etc., for this)
85 self.recommender_agent.post_implicit_feedback(
86 app.pkgname,
87 RecommenderFeedbackActions.VIEWED)
7988
80 def _on_transaction_started(self, backend, pkgname, appname, trans_id,89 def _on_transaction_started(self, backend, pkgname, appname, trans_id,
81 trans_type):90 trans_type):
@@ -89,7 +98,9 @@
89 if result.pkgname in self.recommended_apps_viewed:98 if result.pkgname in self.recommended_apps_viewed:
90 self.recommended_apps_viewed.remove(result.pkgname)99 self.recommended_apps_viewed.remove(result.pkgname)
91 if network_state_is_connected():100 if network_state_is_connected():
92 # no need to monitor for an error, etc., for this101 # let the recommendations service know that a
102 # recommended item has been successfully installed
103 # (there is no need to monitor for an error, etc., for this)
93 self.recommender_agent.post_implicit_feedback(104 self.recommender_agent.post_implicit_feedback(
94 result.pkgname,105 result.pkgname,
95 RecommenderFeedbackActions.INSTALLED)106 RecommenderFeedbackActions.INSTALLED)
96107
=== modified file 'tests/gtk3/test_catview.py'
--- tests/gtk3/test_catview.py 2012-09-11 12:53:37 +0000
+++ tests/gtk3/test_catview.py 2012-09-11 14:47:19 +0000
@@ -271,6 +271,32 @@
271 self.assertFalse(self._app.pkgname in271 self.assertFalse(self._app.pkgname in
272 self.rec_panel.recommended_apps_viewed)272 self.rec_panel.recommended_apps_viewed)
273 273
274 def test_implicit_recommender_feedback_on_item_viewed(self):
275 self._opt_in_and_populate_recommended_for_you_panel()
276 # we fake the callback from the agent here
277 for_you = self.rec_panel.recommended_for_you_cat
278 for_you._recommend_me_result(None,
279 make_recommender_agent_recommend_me_dict())
280 do_events()
281
282 post_implicit_feedback_fn = ('softwarecenter.ui.gtk3.widgets'
283 '.recommendations.RecommenderAgent'
284 '.post_implicit_feedback')
285 with patch(post_implicit_feedback_fn) as mock_post_implicit_feedback:
286 # we want to grab the app that is activated, it will be in
287 # self._app after the app is activated on the tile click
288 self.rec_panel.recommended_for_you_content.connect(
289 "application-activated",
290 self._on_application_activated)
291 # click a recommendation in the lobby
292 self._click_first_tile_in_panel(self.rec_panel)
293 # and verify that upon selecting a recommended app we have fired
294 # the implicit feedback call to the recommender with the correct
295 # arguments
296 mock_post_implicit_feedback.assert_called_with(
297 self._app.pkgname,
298 RecommenderFeedbackActions.VIEWED)
299
274 def test_implicit_recommender_feedback_recommendations_panel_only(self):300 def test_implicit_recommender_feedback_recommendations_panel_only(self):
275 # this test insures that we only provide feedback when installing301 # this test insures that we only provide feedback when installing
276 # items clicked to via the recommendations panel itself, and not302 # items clicked to via the recommendations panel itself, and not

Subscribers

People subscribed via source and target branches