Merge lp:~diegosarmentero/ubuntuone-client/ubuntuone-client-menuorder into lp:ubuntuone-client

Proposed by Diego Sarmentero
Status: Merged
Approved by: Diego Sarmentero
Approved revision: 1330
Merged at revision: 1326
Proposed branch: lp:~diegosarmentero/ubuntuone-client/ubuntuone-client-menuorder
Merge into: lp:ubuntuone-client
Prerequisite: lp:~diegosarmentero/ubuntuone-client/ubuntuone-client-timer
Diff against target: 92 lines (+45/-11)
2 files modified
tests/platform/sync_menu/test_linux.py (+34/-4)
ubuntuone/platform/sync_menu/linux.py (+11/-7)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-client/ubuntuone-client-menuorder
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
dobey (community) Approve
Review via email: mp+125768@code.launchpad.net

Commit message

- Sort items based on the written value, to prioritize the files being transferred (LP: #1052956).

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

The implications of how this might behave, frighten me a little. A video showing this in action in an open transfers menu, which remains open for many (at least 30) seconds, would be quite helpful.

But based on the bug report, and that this code will presumably be updated many times while the menu is being examined by a user, it seems like the ordering may change. And having menu items constantly changing position would be quite disturbing for the user; even if the menu items are not clickable (as they do not seem to be).

review: Needs Information
1325. By Diego Sarmentero

merge

Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

> The implications of how this might behave, frighten me a little. A video
> showing this in action in an open transfers menu, which remains open for many
> (at least 30) seconds, would be quite helpful.
>
> But based on the bug report, and that this code will presumably be updated
> many times while the menu is being examined by a user, it seems like the
> ordering may change. And having menu items constantly changing position would
> be quite disturbing for the user; even if the menu items are not clickable (as
> they do not seem to be).

This is the video i showed you on irc: http://youtu.be/qOmaBCayQAo

Take into account that i'm not deleting all the items and recreating the menu with the ones that has the highest written value, but just deleting the ones that complete the transfer, and always prioritizing the ones with the highest written value to put in those places.

Revision history for this message
dobey (dobey) :
review: Approve
1326. By Diego Sarmentero

fixing tests

1327. By Diego Sarmentero

tests updated

1328. By Diego Sarmentero

merge

1329. By Diego Sarmentero

merge

1330. By Diego Sarmentero

merge

Revision history for this message
Manuel de la Peña (mandel) wrote :

I really like the use of itemgetter. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/platform/sync_menu/test_linux.py'
--- tests/platform/sync_menu/test_linux.py 2012-09-26 20:24:20 +0000
+++ tests/platform/sync_menu/test_linux.py 2012-09-26 20:24:20 +0000
@@ -343,13 +343,43 @@
343 linux.SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE),343 linux.SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE),
344 percentage)344 percentage)
345345
346 def test_transfers_order(self):
347 """Check that the proper transfers are shown first."""
348 data_current = [
349 ('file0', 1200, 610),
350 ('file1', 3000, 400),
351 ('file2', 2000, 100),
352 ('file3', 2500, 150),
353 ('file4', 2500, 950),
354 ('file5', 3500, 550),
355 ('file6', 1000, 600),
356 ('file7', 5000, 4600)]
357 expected = [
358 ('file7', 5000, 4600),
359 ('file4', 2500, 950),
360 ('file0', 1200, 610),
361 ('file6', 1000, 600),
362 ('file5', 3500, 550)]
363 self.status_frontend.uploading_data = data_current
364 self.sync_menu.transfers.update_progress()
365 children = self.sync_menu.transfers.get_children()
366 # The menu should only show 5 current transfers.
367 self.assertEqual(len(children), 5)
368 for i, item in enumerate(children):
369 text = item.property_get(linux.Dbusmenu.MENUITEM_PROP_LABEL)
370 percentage = item.property_get_int(
371 linux.SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE)
372 name, size, written = expected[i]
373 percentage_expected = written * 100 / size
374 self.assertEqual(text, name)
375 self.assertEqual(percentage, percentage_expected)
376
346 def test_update_transfers_delay(self):377 def test_update_transfers_delay(self):
347 """Check that the timer is being handle properly."""378 """Check that the timer is being handle properly."""
348 self.patch(linux.status.aggregator, "Timer", FakeTimer)379 self.patch(linux.status.aggregator, "Timer", FakeTimer)
349 self.sync_menu.next_update = time.time() + 3380 self.sync_menu.next_update = time.time()
350 self.sync_menu.update_transfers()381 self.sync_menu.update_transfers()
351 self.assertLess(self.sync_menu.timer.delay, 3)
352 self.sync_menu.timer = None382 self.sync_menu.timer = None
353 self.sync_menu.next_update = time.time() / 2383 self.sync_menu.next_update = time.time() * 2
354 self.sync_menu.update_transfers()384 self.sync_menu.update_transfers()
355 self.assertEqual(self.sync_menu.timer.delay, 0)385 self.assertEqual(self.sync_menu.timer.delay, 3)
356386
=== modified file 'ubuntuone/platform/sync_menu/linux.py'
--- ubuntuone/platform/sync_menu/linux.py 2012-09-26 20:24:20 +0000
+++ ubuntuone/platform/sync_menu/linux.py 2012-09-26 20:24:20 +0000
@@ -33,6 +33,8 @@
33import time33import time
34import sys34import sys
35import webbrowser35import webbrowser
36from collections import OrderedDict
37from operator import itemgetter
3638
37glib = None39glib = None
38try:40try:
@@ -182,18 +184,20 @@
182184
183 def update_progress(self):185 def update_progress(self):
184 """Update the list of recent transfers and current transfers."""186 """Update the list of recent transfers and current transfers."""
185 current_transfers = self.status_frontend.recent_transfers()187 recent_transfers = self.status_frontend.recent_transfers()
186 uploading_data = {}188 current_transfers = self.status_frontend.files_uploading()
187 for filename, size, written in \189 current_transfers.sort(key=itemgetter(2))
188 self.status_frontend.files_uploading():190 current_transfers.reverse()
191 uploading_data = OrderedDict()
192 for filename, size, written in current_transfers:
189 uploading_data[filename] = (size, written)193 uploading_data[filename] = (size, written)
190194
191 temp_transfers = {}195 temp_transfers = {}
192 if current_transfers != self.previous_transfers:196 if recent_transfers != self.previous_transfers:
193 logger.debug("Update recent transfers with: %r", current_transfers)197 logger.debug("Update recent transfers with: %r", recent_transfers)
194 for item_transfer in self._transfers_items:198 for item_transfer in self._transfers_items:
195 self.child_delete(self._transfers_items[item_transfer])199 self.child_delete(self._transfers_items[item_transfer])
196 for item in current_transfers:200 for item in recent_transfers:
197 recent_file = Dbusmenu.Menuitem()201 recent_file = Dbusmenu.Menuitem()
198 recent_file.property_set(Dbusmenu.MENUITEM_PROP_LABEL,202 recent_file.property_set(Dbusmenu.MENUITEM_PROP_LABEL,
199 item)203 item)

Subscribers

People subscribed via source and target branches