Modify search autocompletion to include only email

When a user's full name is included in the query, the search excludes
commits where the full name does not appear in the author line. This may
be a subset of the actual changes pertaining to the user.

With this change, the search autocomplete results are instead generated
to only include the email when it is known.

Bug: Issue 7053
Change-Id: I4e20d6388f7b904c63786b9e87f9880a0f519b7e
This commit is contained in:
Kasper Nilsson
2017-11-21 11:43:52 -08:00
parent 3d97b49cdd
commit a226fd8698
2 changed files with 7 additions and 13 deletions

View File

@@ -189,14 +189,9 @@
MAX_AUTOCOMPLETE_RESULTS) MAX_AUTOCOMPLETE_RESULTS)
.then(accounts => { .then(accounts => {
if (!accounts) { return []; } if (!accounts) { return []; }
return accounts.map(acct => { return accounts.map(acct => acct.email ?
if (acct.email) { `${predicate}:${acct.email}` :
return predicate + ':"' + this._accountOrAnon(acct) + `${predicate}:"${this._accountOrAnon(acct)}"`);
' <' + acct.email + '>"';
} else {
return predicate + ':"' + this._accountOrAnon(acct) + '"';
}
});
}).then(accounts => { }).then(accounts => {
// When the expression supplied is a beginning substring of 'self', // When the expression supplied is a beginning substring of 'self',
// add it as an autocomplete option. // add it as an autocomplete option.

View File

@@ -105,7 +105,7 @@ limitations under the License.
}); });
suite('_getSearchSuggestions', () => { suite('_getSearchSuggestions', () => {
test('Autocompletes accounts', done => { test('Autocompletes accounts', () => {
sandbox.stub(element.$.restAPI, 'getSuggestedAccounts', () => sandbox.stub(element.$.restAPI, 'getSuggestedAccounts', () =>
Promise.resolve([ Promise.resolve([
{ {
@@ -114,9 +114,8 @@ limitations under the License.
}, },
]) ])
); );
element._getSearchSuggestions('owner:fr').then(s => { return element._getSearchSuggestions('owner:fr').then(s => {
assert.equal(s[0].value, 'owner:"fred <fred@goog.co>"'); assert.equal(s[0].value, 'owner:fred@goog.co');
done();
}); });
}); });
@@ -257,7 +256,7 @@ limitations under the License.
]) ])
); );
element._getSearchSuggestions('owner:fr').then(s => { element._getSearchSuggestions('owner:fr').then(s => {
assert.equal(s[0].value, 'owner:"Anonymous <fred@goog.co>"'); assert.equal(s[0].value, 'owner:fred@goog.co');
done(); done();
}); });
}); });