InlineEdit: Add "has:edit" search operator

Index a field "editby" with a value for each account ID that has an
edit on this change. Intentionally don't expose editby:'USER' because
only change edit owners can see them.

Given that "has:edit" predicate outcome depends on the existence of
the change edit ref and not on its content, only reindex the changes
on change edit ref creation and deletion, but not on its mutation.

Bug: Issue 3291
Change-Id: I2d541c781d057cdf9dcacfc02f81591ce6872595
This commit is contained in:
David Ostrovsky
2015-04-30 23:48:35 +02:00
parent 7dc16f2154
commit 9952870b5e
13 changed files with 197 additions and 7 deletions

View File

@@ -145,6 +145,14 @@ public final class Change {
return null;
}
public static Id fromEditRefPart(String ref) {
int startChangeId = ref.indexOf(RefNames.EDIT_PREFIX) +
RefNames.EDIT_PREFIX.length();
int endChangeId = nextNonDigit(ref, startChangeId);
String id = ref.substring(startChangeId, endChangeId);
return new Change.Id(Integer.parseInt(id));
}
static int startIndex(String ref) {
if (ref == null || !ref.startsWith(REFS_CHANGES)) {
return -1;

View File

@@ -55,6 +55,8 @@ public class RefNames {
/** Suffix of a meta ref in the notedb. */
public static final String META_SUFFIX = "/meta";
public static final String EDIT_PREFIX = "edit-";
public static String fullName(String ref) {
return (ref.startsWith(REFS) ? "" : REFS_HEADS) + ref;
}
@@ -119,9 +121,10 @@ public class RefNames {
*/
public static String refsEditPrefix(Account.Id accountId, Change.Id changeId) {
return new StringBuilder(refsUsers(accountId))
.append("/edit-")
.append('/')
.append(EDIT_PREFIX)
.append(changeId.get())
.append("/")
.append('/')
.toString();
}