From 6cfcb37ee5fe94d14cae08ec2d713ae41c5f7d48 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sun, 26 Feb 2017 09:57:41 +0100 Subject: [PATCH] Add field for wip changes to index and QueryBuilder The reviewer predicate was amended to exclude wip changes. This is needed to take wip changes down from reviewers dashboards that use this search predicate to present changes for review. Change-Id: I9612759c0437188c22a6aceba72c367b51e09876 --- Documentation/user-search.txt | 5 +++++ .../google/gerrit/client/SearchSuggestOracle.java | 1 + .../gerrit/server/index/change/ChangeField.java | 4 ++++ .../index/change/ChangeSchemaDefinitions.java | 3 ++- .../server/query/change/ChangeQueryBuilder.java | 13 +++++++++++-- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Documentation/user-search.txt b/Documentation/user-search.txt index d49ed3f5d5..74ae568c9c 100644 --- a/Documentation/user-search.txt +++ b/Documentation/user-search.txt @@ -378,6 +378,11 @@ is:private:: True if the change is private, ie. only visible to owner and its reviewers. +[[workInProgress]] +is:wip:: ++ +True if the change is Work In Progress. + [[status]] status:open, status:pending:: + diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/SearchSuggestOracle.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/SearchSuggestOracle.java index 52da8e658c..cb947feb35 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/SearchSuggestOracle.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/SearchSuggestOracle.java @@ -137,6 +137,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle { suggestions.add("is:abandoned"); suggestions.add("is:mergeable"); suggestions.add("is:ignored"); + suggestions.add("is:wip"); suggestions.add("status:"); suggestions.add("status:open"); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeField.java b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeField.java index 0f6e89e940..8765607531 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeField.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeField.java @@ -428,6 +428,10 @@ public class ChangeField { public static final FieldDef PRIVATE = exact(ChangeQueryBuilder.FIELD_PRIVATE).build(cd -> cd.change().isPrivate() ? "1" : "0"); + /** Determines if this change is work in progress. */ + public static final FieldDef WIP = + exact(ChangeQueryBuilder.FIELD_WIP).build(cd -> cd.change().isWorkInProgress() ? "1" : "0"); + /** Users who have commented on this change. */ public static final FieldDef> COMMENTBY = integer(ChangeQueryBuilder.FIELD_COMMENTBY) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java index 35d84b8390..ec507f42ec 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java @@ -71,8 +71,9 @@ public class ChangeSchemaDefinitions extends SchemaDefinitions { ChangeField.UPDATED); @Deprecated static final Schema V40 = schema(V39, ChangeField.PRIVATE); + @Deprecated static final Schema V41 = schema(V40, ChangeField.REVIEWER_BY_EMAIL); - static final Schema V41 = schema(V40, ChangeField.REVIEWER_BY_EMAIL); + static final Schema V42 = schema(V41, ChangeField.WIP); public static final String NAME = "changes"; public static final ChangeSchemaDefinitions INSTANCE = new ChangeSchemaDefinitions(); 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 f4bc629250..22e8d58ffa 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 @@ -168,6 +168,7 @@ public class ChangeQueryBuilder extends QueryBuilder { public static final String FIELD_UNRESOLVED_COMMENT_COUNT = "unresolved"; public static final String FIELD_VISIBLETO = "visibleto"; public static final String FIELD_WATCHEDBY = "watchedby"; + public static final String FIELD_WIP = "wip"; public static final String ARG_ID_USER = "user"; public static final String ARG_ID_GROUP = "group"; @@ -571,7 +572,9 @@ public class ChangeQueryBuilder extends QueryBuilder { } if ("reviewer".equalsIgnoreCase(value)) { - return ReviewerPredicate.reviewer(args, self()); + return Predicate.and( + Predicate.not(new BooleanPredicate(ChangeField.WIP, args.fillArgs)), + ReviewerPredicate.reviewer(args, self())); } if ("cc".equalsIgnoreCase(value)) { @@ -602,6 +605,10 @@ public class ChangeQueryBuilder extends QueryBuilder { return star("ignore"); } + if ("wip".equalsIgnoreCase(value)) { + return new BooleanPredicate(ChangeField.WIP, args.fillArgs); + } + try { return status(value); } catch (IllegalArgumentException e) { @@ -955,7 +962,9 @@ public class ChangeQueryBuilder extends QueryBuilder { @Operator public Predicate reviewer(String who) throws QueryParseException, OrmException { - return reviewerByState(who, ReviewerStateInternal.REVIEWER); + return Predicate.and( + Predicate.not(new BooleanPredicate(ChangeField.WIP, args.fillArgs)), + reviewerByState(who, ReviewerStateInternal.REVIEWER)); } @Operator