Merge lp:~gmb/launchpad/hide-update-now-on-success-bug-566605 into lp:launchpad

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 10867
Proposed branch: lp:~gmb/launchpad/hide-update-now-on-success-bug-566605
Merge into: lp:launchpad
Prerequisite: lp:~gmb/launchpad/retry-rofo-watches-bug-566600
Diff against target: 126 lines (+51/-5)
3 files modified
lib/lp/bugs/doc/bugwatch.txt (+28/-1)
lib/lp/bugs/model/bugwatch.py (+5/-0)
lib/lp/bugs/stories/bugwatches/xx-edit-bugwatch.txt (+18/-4)
To merge this branch: bzr merge lp:~gmb/launchpad/hide-update-now-on-success-bug-566605
Reviewer Review Type Date Requested Status
Michael Nelson (community) code Approve
Review via email: mp+25228@code.launchpad.net

Commit message

The 'Update now' button will no longer appear for a bug watch whose latest update succeeded.

Description of the change

This branch fixes bug 566605 by preventing the "Update now" button from appearing for bug watches whose last update succeeded, regardless of how often they've failed in the past.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/doc/bugwatch.txt'
--- lib/lp/bugs/doc/bugwatch.txt 2010-04-23 11:19:49 +0000
+++ lib/lp/bugs/doc/bugwatch.txt 2010-05-14 13:11:29 +0000
@@ -537,7 +537,10 @@
537If the watch's updates have failed less than 60% of the time,537If the watch's updates have failed less than 60% of the time,
538can_be_rescheduled will be True538can_be_rescheduled will be True
539539
540 >>> import transaction
540 >>> from lp.bugs.interfaces.bugwatch import BugWatchActivityStatus541 >>> from lp.bugs.interfaces.bugwatch import BugWatchActivityStatus
542
543 >>> transaction.commit()
541 >>> schedulable_watch.addActivity(544 >>> schedulable_watch.addActivity(
542 ... result=BugWatchActivityStatus.BUG_NOT_FOUND)545 ... result=BugWatchActivityStatus.BUG_NOT_FOUND)
543 >>> schedulable_watch.can_be_rescheduled546 >>> schedulable_watch.can_be_rescheduled
@@ -558,11 +561,32 @@
558needs attention in order for it to be able to work again.561needs attention in order for it to be able to work again.
559562
560 >>> schedulable_watch.next_check = None563 >>> schedulable_watch.next_check = None
564 >>> transaction.commit()
561 >>> schedulable_watch.addActivity(565 >>> schedulable_watch.addActivity(
562 ... result=BugWatchActivityStatus.BUG_NOT_FOUND)566 ... result=BugWatchActivityStatus.BUG_NOT_FOUND)
563 >>> schedulable_watch.can_be_rescheduled567 >>> schedulable_watch.can_be_rescheduled
564 False568 False
565569
570If the watch has run and failed only once, can_be_rescheduled will be
571true.
572
573 >>> from datetime import timedelta
574 >>> run_once_failed_once_watch = factory.makeBugWatch()
575 >>> run_once_failed_once_watch.next_check = (
576 ... datetime.now(utc) + timedelta(days=7))
577 >>> run_once_failed_once_watch.addActivity(
578 ... result=BugWatchActivityStatus.BUG_NOT_FOUND)
579 >>> run_once_failed_once_watch.can_be_rescheduled
580 True
581
582If the most recent update on the watch succeded, can_be_rescheduled will
583be False, regardless of the ratio of failures to successes.
584
585 >>> transaction.commit()
586 >>> run_once_failed_once_watch.addActivity()
587 >>> run_once_failed_once_watch.can_be_rescheduled
588 False
589
566590
567Rescheduling a watch591Rescheduling a watch
568--------------------592--------------------
@@ -575,6 +599,8 @@
575The schedulable_watch that we used in the previous test cannot currently599The schedulable_watch that we used in the previous test cannot currently
576be rescheduled.600be rescheduled.
577601
602 >>> schedulable_watch = factory.makeBugWatch()
603 >>> schedulable_watch.next_check = None
578 >>> schedulable_watch.can_be_rescheduled604 >>> schedulable_watch.can_be_rescheduled
579 False605 False
580606
@@ -589,7 +615,8 @@
589If we add some activity to the watch, to make its can_be_rescheduled615If we add some activity to the watch, to make its can_be_rescheduled
590property become True, setNextCheck() will succeed.616property become True, setNextCheck() will succeed.
591617
592 >>> schedulable_watch.addActivity()618 >>> schedulable_watch.addActivity(
619 ... result=BugWatchActivityStatus.BUG_NOT_FOUND)
593 >>> schedulable_watch.can_be_rescheduled620 >>> schedulable_watch.can_be_rescheduled
594 True621 True
595622
596623
=== modified file 'lib/lp/bugs/model/bugwatch.py'
--- lib/lp/bugs/model/bugwatch.py 2010-05-13 12:02:00 +0000
+++ lib/lp/bugs/model/bugwatch.py 2010-05-14 13:11:29 +0000
@@ -345,6 +345,11 @@
345 # been checked.345 # been checked.
346 return False346 return False
347347
348 if self.activity[0].result in BUG_WATCH_ACTIVITY_SUCCESS_STATUSES:
349 # If the last update was successful the watch can't be
350 # rescheduled.
351 return False
352
348 if self.failed_activity.is_empty():353 if self.failed_activity.is_empty():
349 # Don't show the reschedule button if the watch has never354 # Don't show the reschedule button if the watch has never
350 # failed.355 # failed.
351356
=== modified file 'lib/lp/bugs/stories/bugwatches/xx-edit-bugwatch.txt'
--- lib/lp/bugs/stories/bugwatches/xx-edit-bugwatch.txt 2010-05-13 12:02:00 +0000
+++ lib/lp/bugs/stories/bugwatches/xx-edit-bugwatch.txt 2010-05-14 13:11:29 +0000
@@ -130,8 +130,6 @@
130130
131For a new watch, the "Update Now" button isn't shown.131For a new watch, the "Update Now" button isn't shown.
132132
133 >>> from pytz import utc
134 >>> from datetime import datetime, timedelta
135 >>> login('foo.bar@canonical.com')133 >>> login('foo.bar@canonical.com')
136 >>> bug_watch = factory.makeBugWatch()134 >>> bug_watch = factory.makeBugWatch()
137 >>> bug_watch.next_check = None135 >>> bug_watch.next_check = None
@@ -203,8 +201,6 @@
203If a watch has run once and failed once, the reschedule button will be201If a watch has run once and failed once, the reschedule button will be
204shown.202shown.
205203
206 >>> from pytz import utc
207 >>> from datetime import datetime, timedelta
208 >>> login('foo.bar@canonical.com')204 >>> login('foo.bar@canonical.com')
209 >>> bug_watch = factory.makeBugWatch()205 >>> bug_watch = factory.makeBugWatch()
210 >>> bug_watch.next_check = None206 >>> bug_watch.next_check = None
@@ -222,3 +218,21 @@
222 ... user_browser.contents, 'informational message'):218 ... user_browser.contents, 'informational message'):
223 ... print extract_text(message)219 ... print extract_text(message)
224 The ... bug watch has been scheduled for immediate checking.220 The ... bug watch has been scheduled for immediate checking.
221
222However, once the watch succeeds the button will disappear, even though
223the watch has failed > 60% of the time. This is because the most recent
224check succeeded, so there's no point in allowing users to reschedule the
225watch for checking.
226
227 >>> from datetime import timedelta
228
229 >>> login('foo.bar@canonical.com')
230 >>> bug_watch.next_check = datetime.now(utc) + timedelta(days=7)
231 >>> bug_watch.addActivity()
232 >>> logout()
233
234 >>> user_browser.open(watch_url)
235 >>> user_browser.getControl('Update Now')
236 Traceback (most recent call last):
237 ...
238 LookupError: label 'Update Now'