{"action":"created","comment":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments/167003317","pull_request_review_id":95155495,"id":167003317,"diff_hunk":"@@ -107,8 +107,8 @@ export function blockAutocompleter( { onReplace } ) {\n  * @returns {Completer} Completer object used by the Autocomplete component.\n  */\n export function userAutocompleter() {\n-\tconst getOptions = () => {\n-\t\treturn ( new wp.api.collections.Users() ).fetch().then( ( users ) => {\n+\tconst getOptions = ( search ) => {\n+\t\treturn ( new wp.api.collections.Users() ).fetch( search ? { data: { search } } : null ).then( ( users ) => {","path":"blocks/autocompleters/index.js","position":null,"original_position":7,"commit_id":"ac62c0098e0a40ace0ec656b37958ea1fec3727d","original_commit_id":"4649a30d60e77110e80091474671201e53e36a25","user":{"login":"adamsilverstein","id":2676022,"avatar_url":"https://avatars0.githubusercontent.com/u/2676022?v=4","gravatar_id":"","url":"https://api.github.com/users/adamsilverstein","html_url":"https://github.com/adamsilverstein","followers_url":"https://api.github.com/users/adamsilverstein/followers","following_url":"https://api.github.com/users/adamsilverstein/following{/other_user}","gists_url":"https://api.github.com/users/adamsilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilverstein/subscriptions","organizations_url":"https://api.github.com/users/adamsilverstein/orgs","repos_url":"https://api.github.com/users/adamsilverstein/repos","events_url":"https://api.github.com/users/adamsilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilverstein/received_events","type":"User","site_admin":false},"body":"good idea, implemented in https://github.com/WordPress/gutenberg/pull/4406/commits/ac62c0098e0a40ace0ec656b37958ea1fec3727d","created_at":"2018-02-08T17:07:47Z","updated_at":"2018-02-08T17:07:47Z","html_url":"https://github.com/WordPress/gutenberg/pull/4406#discussion_r167003317","pull_request_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/4406","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments/167003317"},"html":{"href":"https://github.com/WordPress/gutenberg/pull/4406#discussion_r167003317"},"pull_request":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/4406"}},"in_reply_to_id":166805333},"pull_request":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/4406","id":162389960,"html_url":"https://github.com/WordPress/gutenberg/pull/4406","diff_url":"https://github.com/WordPress/gutenberg/pull/4406.diff","patch_url":"https://github.com/WordPress/gutenberg/pull/4406.patch","issue_url":"https://api.github.com/repos/WordPress/gutenberg/issues/4406","number":4406,"state":"open","locked":false,"title":"User autocomplete should used debounced search request","user":{"login":"adamsilverstein","id":2676022,"avatar_url":"https://avatars0.githubusercontent.com/u/2676022?v=4","gravatar_id":"","url":"https://api.github.com/users/adamsilverstein","html_url":"https://github.com/adamsilverstein","followers_url":"https://api.github.com/users/adamsilverstein/followers","following_url":"https://api.github.com/users/adamsilverstein/following{/other_user}","gists_url":"https://api.github.com/users/adamsilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilverstein/subscriptions","organizations_url":"https://api.github.com/users/adamsilverstein/orgs","repos_url":"https://api.github.com/users/adamsilverstein/repos","events_url":"https://api.github.com/users/adamsilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilverstein/received_events","type":"User","site_admin":false},"body":"## Description\r\nLooking into user autocomplete (typing `@` and then starting to type a username, see https://github.com/WordPress/gutenberg/pull/2896), specifically the code for `userAutocompleter`: currently, it attempts to load all users with a single fetch via `new wp.api.collections.Users() ).fetch().then( ( users ) => {...`.  While this works for testing with a few users, it is not scalable. By default the REST API users endpoint returns 10 users and the default maximum for REST requests is 100 records. Some sites might have hundreds or even thousands of users, so the filtering applied as you type won't work.\r\n\r\nThis should instead use a debounced search. Every time the user types and pauses briefly, fire off a request to the REST API with the typed search string, this will work: `new wp.api.collections.Users() ).fetch( { data: { search: searchString } } ).then( ( users ) => {...`. \r\n\r\nAddresses https://github.com/WordPress/gutenberg/issues/2793#issuecomment-356822668\r\n\r\n## How Has This Been Tested/How to test\r\n* Load a post and type `@` and start typing a username. \r\n* Check the network console, you will see requests being sent with a search string\r\n* Note the requests are sent at most every 250ms which should feel immediate while preventing over requesting\r\n\r\n## Screenshots (jpeg or gifs if applicable):\r\n![](https://cl.ly/0Y342y360p2B/Image%202018-01-11%20at%208.55.44%20AM.png)\r\n\r\n## Types of changes\r\n* debounce search callback is autocompleters/index.js\r\n* in search callback, in autocompleter popover is open and selected autocompleter exposes a `setSearch` function, calls this function with the current search string on every (debounced)  input event\r\n\r\n## Checklist:\r\n- [x] My code is tested.\r\n- [x] My code follows the WordPress code style.\r\n- [x] My code follows has proper inline documentation.","created_at":"2018-01-11T14:01:16Z","updated_at":"2018-02-08T17:07:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ae9bcf08191e982eb5f7c8e1939fc6884390d2cc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/4406/commits","review_comments_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/4406/comments","review_comment_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/issues/4406/comments","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/ac62c0098e0a40ace0ec656b37958ea1fec3727d","head":{"label":"WordPress:feature/autocomplete-user-searching","ref":"feature/autocomplete-user-searching","sha":"ac62c0098e0a40ace0ec656b37958ea1fec3727d","user":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"repo":{"id":80862584,"name":"gutenberg","full_name":"WordPress/gutenberg","owner":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WordPress/gutenberg","description":"Printing since 1440. Development hub for the editor focus in core. Beta plugin is available from the official WordPress repository.","fork":false,"url":"https://api.github.com/repos/WordPress/gutenberg","forks_url":"https://api.github.com/repos/WordPress/gutenberg/forks","keys_url":"https://api.github.com/repos/WordPress/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WordPress/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WordPress/gutenberg/teams","hooks_url":"https://api.github.com/repos/WordPress/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/WordPress/gutenberg/events","assignees_url":"https://api.github.com/repos/WordPress/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/WordPress/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/WordPress/gutenberg/tags","blobs_url":"https://api.github.com/repos/WordPress/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WordPress/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WordPress/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/WordPress/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/WordPress/gutenberg/languages","stargazers_url":"https://api.github.com/repos/WordPress/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/WordPress/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/WordPress/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/WordPress/gutenberg/subscription","commits_url":"https://api.github.com/repos/WordPress/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/WordPress/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/WordPress/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/WordPress/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WordPress/gutenberg/merges","archive_url":"https://api.github.com/repos/WordPress/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WordPress/gutenberg/downloads","issues_url":"https://api.github.com/repos/WordPress/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/WordPress/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/WordPress/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/WordPress/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WordPress/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/WordPress/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/WordPress/gutenberg/deployments","created_at":"2017-02-03T19:34:19Z","updated_at":"2018-02-08T17:04:09Z","pushed_at":"2018-02-08T17:06:56Z","git_url":"git://github.com/WordPress/gutenberg.git","ssh_url":"git@github.com:WordPress/gutenberg.git","clone_url":"https://github.com/WordPress/gutenberg.git","svn_url":"https://github.com/WordPress/gutenberg","homepage":"https://wordpress.org/plugins/gutenberg/ ","size":9897,"stargazers_count":1898,"watchers_count":1898,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":418,"mirror_url":null,"archived":false,"open_issues_count":744,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":418,"open_issues":744,"watchers":1898,"default_branch":"master"}},"base":{"label":"WordPress:master","ref":"master","sha":"d6a8a91827acacbc389fba957741dd278fe7a7f9","user":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"repo":{"id":80862584,"name":"gutenberg","full_name":"WordPress/gutenberg","owner":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WordPress/gutenberg","description":"Printing since 1440. Development hub for the editor focus in core. Beta plugin is available from the official WordPress repository.","fork":false,"url":"https://api.github.com/repos/WordPress/gutenberg","forks_url":"https://api.github.com/repos/WordPress/gutenberg/forks","keys_url":"https://api.github.com/repos/WordPress/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WordPress/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WordPress/gutenberg/teams","hooks_url":"https://api.github.com/repos/WordPress/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/WordPress/gutenberg/events","assignees_url":"https://api.github.com/repos/WordPress/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/WordPress/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/WordPress/gutenberg/tags","blobs_url":"https://api.github.com/repos/WordPress/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WordPress/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WordPress/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/WordPress/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/WordPress/gutenberg/languages","stargazers_url":"https://api.github.com/repos/WordPress/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/WordPress/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/WordPress/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/WordPress/gutenberg/subscription","commits_url":"https://api.github.com/repos/WordPress/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/WordPress/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/WordPress/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/WordPress/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WordPress/gutenberg/merges","archive_url":"https://api.github.com/repos/WordPress/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WordPress/gutenberg/downloads","issues_url":"https://api.github.com/repos/WordPress/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/WordPress/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/WordPress/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/WordPress/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WordPress/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/WordPress/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/WordPress/gutenberg/deployments","created_at":"2017-02-03T19:34:19Z","updated_at":"2018-02-08T17:04:09Z","pushed_at":"2018-02-08T17:06:56Z","git_url":"git://github.com/WordPress/gutenberg.git","ssh_url":"git@github.com:WordPress/gutenberg.git","clone_url":"https://github.com/WordPress/gutenberg.git","svn_url":"https://github.com/WordPress/gutenberg","homepage":"https://wordpress.org/plugins/gutenberg/ ","size":9897,"stargazers_count":1898,"watchers_count":1898,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":418,"mirror_url":null,"archived":false,"open_issues_count":744,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":418,"open_issues":744,"watchers":1898,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/4406"},"html":{"href":"https://github.com/WordPress/gutenberg/pull/4406"},"issue":{"href":"https://api.github.com/repos/WordPress/gutenberg/issues/4406"},"comments":{"href":"https://api.github.com/repos/WordPress/gutenberg/issues/4406/comments"},"review_comments":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/4406/comments"},"review_comment":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/4406/commits"},"statuses":{"href":"https://api.github.com/repos/WordPress/gutenberg/statuses/ac62c0098e0a40ace0ec656b37958ea1fec3727d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"adamsilverstein"}}