Move change batch loading from ChangeData to ChangeNotes.Factory

All remaining code that loads changes in batches from the database
should go into ChangeNotes.Factory.

Change-Id: I37170a6b6fbc8d179c0467a41f0551fac3198f20
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin 2016-02-12 14:19:08 +01:00
parent eec1c4856d
commit a048124c8e
2 changed files with 23 additions and 2 deletions

View File

@ -231,6 +231,26 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
change.getProject(), change).load();
}
public List<ChangeNotes> create(ReviewDb db,
Collection<Change.Id> changeIds) throws OrmException {
List<ChangeNotes> notes = new ArrayList<>();
if (migration.enabled()) {
for (Change.Id changeId : changeIds) {
try {
notes.add(createChecked(changeId));
} catch (NoSuchChangeException e) {
// Ignore missing changes to match Access#get(Iterable) behavior.
}
}
return notes;
}
for (Change c : db.changes().get(changeIds)) {
notes.add(createFromChangeOnlyWhenNotedbDisabled(c));
}
return notes;
}
public List<ChangeNotes> create(ReviewDb db, Project.NameKey project,
Collection<Change.Id> changeIds, Predicate<ChangeNotes> predicate)
throws OrmException {

View File

@ -128,8 +128,9 @@ public class ChangeData {
if (missing.isEmpty()) {
return;
}
for (Change change : first.db.changes().get(missing.keySet())) {
missing.get(change.getId()).change = change;
for (ChangeNotes notes : first.notesFactory.create(
first.db, missing.keySet())) {
missing.get(notes.getChangeId()).change = notes.getChange();
}
}