Factor out approvals change status syncing

The changeOpen status is cached in the PatchSetApprovals
table for performance reasons, so the approvals must
be updated whenever the change status changes.  This
update is done in a few places and is likely not
ever obvious why the update is being done.  Make
a function to do the update which makes the code
self documenting all while sharing the
implementation.  Create an new ApprovalsUtil class
for this function which can be a good place for
more approval manipulating functions in the future.

Change-Id: If92f3757963048a141003304f2c96036c915ab89
This commit is contained in:
Martin Fick
2012-01-31 19:20:21 -07:00
parent 07a85820a6
commit 052918a23a
3 changed files with 39 additions and 12 deletions

View File

@@ -403,12 +403,7 @@ public class ChangeUtil {
}
db.changeMessages().insert(Collections.singleton(cmsg));
final List<PatchSetApproval> approvals =
db.patchSetApprovals().byChange(change.getId()).toList();
for (PatchSetApproval a : approvals) {
a.cache(change);
}
db.patchSetApprovals().update(approvals);
ApprovalsUtil.syncChangeStatus(db, change);
// Email the reviewers
final ReplyToChangeSender cm = senderFactory.create(change);