Merge "Accounts: Add method to get all accounts"

This commit is contained in:
Edwin Kempin
2017-06-13 11:52:40 +00:00
committed by Gerrit Code Review
2 changed files with 14 additions and 2 deletions

View File

@@ -49,6 +49,15 @@ public class Accounts {
return db.accounts().get(accountId);
}
/**
* Returns all accounts.
*
* @return all accounts
*/
public List<Account> all(ReviewDb db) throws OrmException {
return db.accounts().all().toList();
}
/**
* Returns all account IDs.
*

View File

@@ -29,18 +29,21 @@ import java.util.List;
@Singleton
public class AccountsConsistencyChecker {
private final Provider<ReviewDb> dbProvider;
private final Accounts accounts;
private final ExternalIds externalIds;
@Inject
AccountsConsistencyChecker(Provider<ReviewDb> dbProvider, ExternalIds externalIds) {
AccountsConsistencyChecker(
Provider<ReviewDb> dbProvider, Accounts accounts, ExternalIds externalIds) {
this.dbProvider = dbProvider;
this.accounts = accounts;
this.externalIds = externalIds;
}
public List<ConsistencyProblemInfo> check() throws OrmException, IOException {
List<ConsistencyProblemInfo> problems = new ArrayList<>();
for (Account account : dbProvider.get().accounts().all()) {
for (Account account : accounts.all(dbProvider.get())) {
if (account.getPreferredEmail() != null) {
if (!externalIds
.byAccount(account.getId())