Fix status:closed query
There was no rewrite rule matching this so the query processor
helpfully ANDed in status:open. Add one.
Change-Id: Ia9afcf0661d6e89d633588db3d0e7f4f60488477
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
index 5ede452..9fc3dbf 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
@@ -557,18 +557,24 @@
return limit(Integer.parseInt(limit));
}
- public Predicate<ChangeData> limit(int limit) {
- return new IntPredicate<ChangeData>(FIELD_LIMIT, limit) {
- @Override
- public boolean match(ChangeData object) {
- return true;
- }
+ static class LimitPredicate extends IntPredicate<ChangeData> {
+ LimitPredicate(int limit) {
+ super(FIELD_LIMIT, limit);
+ }
- @Override
- public int getCost() {
- return 0;
- }
- };
+ @Override
+ public boolean match(ChangeData object) {
+ return true;
+ }
+
+ @Override
+ public int getCost() {
+ return 0;
+ }
+ }
+
+ public Predicate<ChangeData> limit(int limit) {
+ return new LimitPredicate(limit);
}
@Operator
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/SqlRewriterImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/SqlRewriterImpl.java
index c94ee12..bcc4859 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/SqlRewriterImpl.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/SqlRewriterImpl.java
@@ -23,6 +23,7 @@
import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.QueryRewriter;
import com.google.gerrit.server.query.RewritePredicate;
+import com.google.gerrit.server.query.change.ChangeQueryBuilder.LimitPredicate;
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.ResultSet;
import com.google.inject.Inject;
@@ -538,6 +539,13 @@
return or(r30_byReviewerOpen(r), r30_byReviewerClosed(r));
}
+ @Rewrite("status:closed")
+ public Predicate<ChangeData> r99_allClosed() {
+ return r20_byClosedNext(
+ new SortKeyPredicate.Before(null, dbProvider, "z"),
+ new LimitPredicate(Integer.MAX_VALUE));
+ }
+
@Rewrite("status:submitted")
public Predicate<ChangeData> r99_allSubmitted() {
return new ChangeSource(50) {