launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #23267
[Merge] lp:~twom/launchpad/rescans-need-join-conditions into lp:launchpad
Tom Wardill has proposed merging lp:~twom/launchpad/rescans-need-join-conditions into lp:launchpad.
Commit message:
Join the getLatest* queries to the Job table to prevent a full scan on access.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1808320 in Launchpad itself: "Add a "manually rescan" link to MPs"
https://bugs.launchpad.net/launchpad/+bug/1808320
For more details, see:
https://code.launchpad.net/~twom/launchpad/rescans-need-join-conditions/+merge/362608
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~twom/launchpad/rescans-need-join-conditions into lp:launchpad.
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2019-01-28 18:09:21 +0000
+++ lib/lp/code/model/branch.py 2019-02-01 14:22:40 +0000
@@ -1303,7 +1303,8 @@
latest_job = IStore(BranchJob).find(
BranchJob,
BranchJob.branch == self,
- BranchJob.job_type == BranchScanJob.class_job_type).order_by(
+ BranchJob.job_type == BranchScanJob.class_job_type,
+ BranchJob.job == Job.id).order_by(
Desc(Job.date_finished)).first()
return latest_job
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2019-01-31 11:33:58 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2019-02-01 14:22:40 +0000
@@ -1231,6 +1231,7 @@
BranchMergeProposalJob,
BranchMergeProposalJob.branch_merge_proposal == self,
BranchMergeProposalJob.job_type == diff_type,
+ BranchMergeProposalJob.job == Job.id,
).order_by(Desc(Job.date_finished)).first()
if latest_preview is not None:
latest_preview = latest_preview.makeDerived()
=== modified file 'lib/lp/code/model/gitrepository.py'
--- lib/lp/code/model/gitrepository.py 2019-01-28 18:09:21 +0000
+++ lib/lp/code/model/gitrepository.py 2019-02-01 14:22:40 +0000
@@ -752,7 +752,8 @@
latest_job = IStore(GitJob).find(
GitJob,
GitJob.repository == self,
- GitJob.job_type == GitRefScanJob.class_job_type).order_by(
+ GitJob.job_type == GitRefScanJob.class_job_type,
+ GitJob.job == Job.id).order_by(
Desc(Job.date_finished)).first()
return latest_job
Follow ups