[IMP] forwardport: avoid a full scan when we just want a boolean

There should only be 1 PR with a given parent at most anyway, but
still if it's a boolean we can stop at the first occurrence if any. pg
might even be able to do something more efficient in that case.
This commit is contained in:
Xavier Morel 2025-02-03 15:14:08 +01:00
parent 981760430c
commit 12ac32e169

View File

@ -248,7 +248,7 @@ class PullRequests(models.Model):
vals['detach_reason'] = f"Head updated from {self.head} to {newhead}"
# if any children, this is an FP PR being updated, enqueue
# updating children
if self.search_count([('parent_id', '=', self.id)]):
if self.search_count([('parent_id', '=', self.id)], limit=1):
self.env['forwardport.updates'].create({
'original_root': self.root_id.id,
'new_root': self.id