Search is:reviewed operator to ChangeIndex
Store "1" on a field if the change has at least one non-zero approval record on the current revision. Change-Id: I22eef3fb9cd778e2eb00b9b0f5097fd90d4271f6
This commit is contained in:
parent
976c7965b8
commit
9279b29da7
@ -49,7 +49,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class ChangeField {
|
||||
/** Increment whenever making schema changes. */
|
||||
public static final int SCHEMA_VERSION = 14;
|
||||
public static final int SCHEMA_VERSION = 15;
|
||||
|
||||
/** Legacy change ID. */
|
||||
public static final FieldDef<ChangeData, Integer> LEGACY_ID =
|
||||
@ -228,6 +228,22 @@ public class ChangeField {
|
||||
}
|
||||
};
|
||||
|
||||
/** Set true if the change has a non-zero label score. */
|
||||
public static final FieldDef<ChangeData, String> REVIEWED =
|
||||
new FieldDef.Single<ChangeData, String>(
|
||||
"reviewed", FieldType.EXACT, false) {
|
||||
@Override
|
||||
public String get(ChangeData input, FillArgs args)
|
||||
throws OrmException {
|
||||
for (PatchSetApproval a : input.currentApprovals(args.db)) {
|
||||
if (a.getValue() != 0) {
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
public static String formatLabel(String label, int value) {
|
||||
return formatLabel(label, value, null);
|
||||
}
|
||||
|
@ -18,15 +18,16 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.query.OperatorPredicate;
|
||||
import com.google.gerrit.server.index.ChangeField;
|
||||
import com.google.gerrit.server.index.IndexPredicate;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
class IsReviewedPredicate extends OperatorPredicate<ChangeData> {
|
||||
class IsReviewedPredicate extends IndexPredicate<ChangeData> {
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
|
||||
IsReviewedPredicate(Provider<ReviewDb> dbProvider) {
|
||||
super(ChangeQueryBuilder.FIELD_IS, "reviewed");
|
||||
super(ChangeField.REVIEWED, "1");
|
||||
this.dbProvider = dbProvider;
|
||||
}
|
||||
|
||||
@ -51,4 +52,9 @@ class IsReviewedPredicate extends OperatorPredicate<ChangeData> {
|
||||
public int getCost() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "is:reviewed";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user