Merge lp:~twom/launchpad/no-rescan-with-no-jobs into lp:launchpad

Proposed by Tom Wardill
Status: Merged
Merged at revision: 18870
Proposed branch: lp:~twom/launchpad/no-rescan-with-no-jobs
Merge into: lp:launchpad
Prerequisite: lp:~twom/launchpad/merge-proposal-rescan-link
Diff against target: 86 lines (+12/-10)
5 files modified
lib/lp/code/browser/branch.py (+3/-3)
lib/lp/code/browser/branchmergeproposal.py (+3/-1)
lib/lp/code/browser/gitrepository.py (+3/-3)
lib/lp/code/browser/tests/test_branch.py (+2/-2)
lib/lp/code/browser/tests/test_gitrepository.py (+1/-1)
To merge this branch: bzr merge lp:~twom/launchpad/no-rescan-with-no-jobs
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Maximiliano Bertacchini (community) Approve
Review via email: mp+362479@code.launchpad.net

Commit message

No scan jobs existing is a valid state, don't show the rescan button in these situations

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

LGTM

review: Approve
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2019-01-23 17:11:52 +0000
+++ lib/lp/code/browser/branch.py 2019-01-31 14:45:54 +0000
@@ -592,10 +592,10 @@
592 def show_rescan_link(self):592 def show_rescan_link(self):
593 """Only show the rescan button if the latest scan has failed"""593 """Only show the rescan button if the latest scan has failed"""
594 scan_job = self.context.getLatestScanJob()594 scan_job = self.context.getLatestScanJob()
595 # If there are no jobs, we failed to create one for some reason,595 # Having no jobs is a valid situation as there is a prune job.
596 # so we should allow a rescan596 # We don't need to allow a rescan
597 if not scan_job:597 if not scan_job:
598 return True598 return False
599 return scan_job.job.status == JobStatus.FAILED599 return scan_job.job.status == JobStatus.FAILED
600600
601 @cachedproperty601 @cachedproperty
602602
=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
--- lib/lp/code/browser/branchmergeproposal.py 2019-01-31 13:48:34 +0000
+++ lib/lp/code/browser/branchmergeproposal.py 2019-01-31 14:45:54 +0000
@@ -801,8 +801,10 @@
801 @property801 @property
802 def show_diff_update_link(self):802 def show_diff_update_link(self):
803 latest_preview = self.context.getLatestDiffUpdateJob()803 latest_preview = self.context.getLatestDiffUpdateJob()
804 # Having no jobs is a valid situation as there is a prune job.
805 # We don't need to allow a rescan
804 if not latest_preview:806 if not latest_preview:
805 return True807 return False
806 return latest_preview.job.status == JobStatus.FAILED808 return latest_preview.job.status == JobStatus.FAILED
807809
808810
809811
=== modified file 'lib/lp/code/browser/gitrepository.py'
--- lib/lp/code/browser/gitrepository.py 2019-01-28 15:36:56 +0000
+++ lib/lp/code/browser/gitrepository.py 2019-01-31 14:45:54 +0000
@@ -446,10 +446,10 @@
446 def show_rescan_link(self):446 def show_rescan_link(self):
447 """Only show the rescan button if the latest scan has failed"""447 """Only show the rescan button if the latest scan has failed"""
448 scan_job = self.context.getLatestScanJob()448 scan_job = self.context.getLatestScanJob()
449 # If there are no jobs, we failed to create one for some reason,449 # Having no jobs is a valid situation as there is a prune job.
450 # so we should allow a rescan450 # We don't need to allow a rescan
451 if not scan_job:451 if not scan_job:
452 return True452 return False
453 return scan_job.job.status == JobStatus.FAILED453 return scan_job.job.status == JobStatus.FAILED
454454
455455
456456
=== modified file 'lib/lp/code/browser/tests/test_branch.py'
--- lib/lp/code/browser/tests/test_branch.py 2019-01-23 18:14:05 +0000
+++ lib/lp/code/browser/tests/test_branch.py 2019-01-31 14:45:54 +0000
@@ -322,7 +322,7 @@
322 branch = self.factory.makeAnyBranch()322 branch = self.factory.makeAnyBranch()
323 view = create_initialized_view(branch, '+index')323 view = create_initialized_view(branch, '+index')
324 result = view.show_rescan_link324 result = view.show_rescan_link
325 self.assertTrue(result)325 self.assertFalse(result)
326326
327 def test_show_rescan_link_latest_didnt_fail(self):327 def test_show_rescan_link_latest_didnt_fail(self):
328 branch = self.factory.makeAnyBranch()328 branch = self.factory.makeAnyBranch()
@@ -646,7 +646,7 @@
646 logout()646 logout()
647 with StormStatementRecorder() as recorder:647 with StormStatementRecorder() as recorder:
648 browser.open(branch_url)648 browser.open(branch_url)
649 self.assertThat(recorder, HasQueryCount(Equals(29)))649 self.assertThat(recorder, HasQueryCount(Equals(30)))
650650
651651
652class TestBranchViewPrivateArtifacts(BrowserTestCase):652class TestBranchViewPrivateArtifacts(BrowserTestCase):
653653
=== modified file 'lib/lp/code/browser/tests/test_gitrepository.py'
--- lib/lp/code/browser/tests/test_gitrepository.py 2019-01-28 17:19:44 +0000
+++ lib/lp/code/browser/tests/test_gitrepository.py 2019-01-31 14:45:54 +0000
@@ -445,7 +445,7 @@
445 repository = self.factory.makeGitRepository()445 repository = self.factory.makeGitRepository()
446 view = create_initialized_view(repository, '+index')446 view = create_initialized_view(repository, '+index')
447 result = view.show_rescan_link447 result = view.show_rescan_link
448 self.assertTrue(result)448 self.assertFalse(result)
449449
450 def test_show_rescan_link_latest_didnt_fail(self):450 def test_show_rescan_link_latest_didnt_fail(self):
451 repository = self.factory.makeGitRepository()451 repository = self.factory.makeGitRepository()