AccountPatchReviewStore: add possibility to cleanReviewed by change

It simplifies the clean up when change gets removed.

Change-Id: I10387b85a80a0fb8d62f686cc8f33c146a856ff3
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
This commit is contained in:
Jacek Centkowski
2019-05-14 12:35:10 +02:00
parent f7b51c3f2c
commit 3dd45c93ff
3 changed files with 24 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.change.AccountPatchReviewStore;
import com.google.gerrit.server.config.ConfigUtil;
@@ -294,6 +295,18 @@ public abstract class JdbcAccountPatchReviewStore
}
}
@Override
public void clearReviewed(Change.Id changeId) {
try (Connection con = ds.getConnection();
PreparedStatement stmt =
con.prepareStatement("DELETE FROM account_patch_reviews WHERE change_id = ?")) {
stmt.setInt(1, changeId.get());
stmt.executeUpdate();
} catch (SQLException e) {
throw convertError("delete", e);
}
}
@Override
public Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId) {
try (Connection con = ds.getConnection();