{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/ghactivity/pulls/comments/232049081","pull_request_review_id":173156969,"id":232049081,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjA0OTA4MQ==","diff_hunk":"@@ -289,4 +290,47 @@ private function get_repo_activity( $repo_name = '' ) {\n \n \t\treturn $this->get_github_data( $query_url );\n \t}\n+\n+\t/**\n+\t * Get the list of repo label names from GH API\n+\t *\n+\t * @since 2.0.0\n+\t *\n+\t * @param string $repo_name Name of the repo we are interested in.\n+\t *\n+\t * @return array Array of repo label names.\n+\t */\n+\tpublic function get_repo_label_names( $repo_name ) {\n+\t\tif ( empty( $repo_name ) ) {\n+\t\t\t// Fallback.\n+\t\t\treturn array();\n+\t\t}\n+\n+\t\t$page       = 1;\n+\t\t$all_labels = array();\n+\t\t$query_url  = sprintf(\n+\t\t\t'https://api.github.com/repos/%1$s/labels?access_token=%2$s&per_page=100',\n+\t\t\t$repo_name,\n+\t\t\t$this->token\n+\t\t);\n+\n+\t\t// Fetch API until empty array will be returned.","path":"github.ghactivity.php","position":40,"original_position":40,"commit_id":"3af876c3e086ba9d55ad0c3bc71efb1bb56ce090","original_commit_id":"3af876c3e086ba9d55ad0c3bc71efb1bb56ce090","user":{"login":"jeherve","id":426388,"node_id":"MDQ6VXNlcjQyNjM4OA==","avatar_url":"https://avatars1.githubusercontent.com/u/426388?v=4","gravatar_id":"","url":"https://api.github.com/users/jeherve","html_url":"https://github.com/jeherve","followers_url":"https://api.github.com/users/jeherve/followers","following_url":"https://api.github.com/users/jeherve/following{/other_user}","gists_url":"https://api.github.com/users/jeherve/gists{/gist_id}","starred_url":"https://api.github.com/users/jeherve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeherve/subscriptions","organizations_url":"https://api.github.com/users/jeherve/orgs","repos_url":"https://api.github.com/users/jeherve/repos","events_url":"https://api.github.com/users/jeherve/events{/privacy}","received_events_url":"https://api.github.com/users/jeherve/received_events","type":"User","site_admin":false},"body":"I like that approach ❤️ ","created_at":"2018-11-08T20:26:38Z","updated_at":"2018-11-08T20:47:09Z","html_url":"https://github.com/Automattic/ghactivity/pull/29#discussion_r232049081","pull_request_url":"https://api.github.com/repos/Automattic/ghactivity/pulls/29","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Automattic/ghactivity/pulls/comments/232049081"},"html":{"href":"https://github.com/Automattic/ghactivity/pull/29#discussion_r232049081"},"pull_request":{"href":"https://api.github.com/repos/Automattic/ghactivity/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/ghactivity/pulls/29","id":229485444,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5NDg1NDQ0","html_url":"https://github.com/Automattic/ghactivity/pull/29","diff_url":"https://github.com/Automattic/ghactivity/pull/29.diff","patch_url":"https://github.com/Automattic/ghactivity/pull/29.patch","issue_url":"https://api.github.com/repos/Automattic/ghactivity/issues/29","number":29,"state":"open","locked":false,"title":"Add/repo label state backend","user":{"login":"brbrr","id":5654161,"node_id":"MDQ6VXNlcjU2NTQxNjE=","avatar_url":"https://avatars2.githubusercontent.com/u/5654161?v=4","gravatar_id":"","url":"https://api.github.com/users/brbrr","html_url":"https://github.com/brbrr","followers_url":"https://api.github.com/users/brbrr/followers","following_url":"https://api.github.com/users/brbrr/following{/other_user}","gists_url":"https://api.github.com/users/brbrr/gists{/gist_id}","starred_url":"https://api.github.com/users/brbrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brbrr/subscriptions","organizations_url":"https://api.github.com/users/brbrr/orgs","repos_url":"https://api.github.com/users/brbrr/repos","events_url":"https://api.github.com/users/brbrr/events{/privacy}","received_events_url":"https://api.github.com/users/brbrr/received_events","type":"User","site_admin":false},"body":"Adds a backend code for Repo Label State. Internal ref on how it might look like: p1HpG7-5Ax-p2\r\n\r\nMost of the magic happens in these methods:\r\n- `current_repo_labels_state` - it get an array of repo-related `ghactivity_issues_labels`, and returns associated array of labels and filtered repo issue slugs.\r\n- `record_current_repo_labels_state` - persists into DB result of `current_repo_labels_state` after removing labels with zero labeled issues and splitting them into categories for ease of use further.\r\n- `fetch_repo_label_state` - loads Repo Label State from the DB. It actually loads 2 records - most recent one (`current_label_state`) and the one which is 1 week old (`previous_label_state`). It is used later on in REST API.\r\n\r\nTo test: Not an easy task! I've used `psysh` to run these methods in REPL environment. It might be worth including some basic UI for ease of testing. I have a shortcode and a basic React Component ready, so if you think it will be easier for you - I'll be happy to include these in this PR. ","created_at":"2018-11-08T19:41:28Z","updated_at":"2018-11-08T20:47:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a72ff6a872afbafd29edc7c982502c9c00d6cea7","assignee":{"login":"brbrr","id":5654161,"node_id":"MDQ6VXNlcjU2NTQxNjE=","avatar_url":"https://avatars2.githubusercontent.com/u/5654161?v=4","gravatar_id":"","url":"https://api.github.com/users/brbrr","html_url":"https://github.com/brbrr","followers_url":"https://api.github.com/users/brbrr/followers","following_url":"https://api.github.com/users/brbrr/following{/other_user}","gists_url":"https://api.github.com/users/brbrr/gists{/gist_id}","starred_url":"https://api.github.com/users/brbrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brbrr/subscriptions","organizations_url":"https://api.github.com/users/brbrr/orgs","repos_url":"https://api.github.com/users/brbrr/repos","events_url":"https://api.github.com/users/brbrr/events{/privacy}","received_events_url":"https://api.github.com/users/brbrr/received_events","type":"User","site_admin":false},"assignees":[{"login":"brbrr","id":5654161,"node_id":"MDQ6VXNlcjU2NTQxNjE=","avatar_url":"https://avatars2.githubusercontent.com/u/5654161?v=4","gravatar_id":"","url":"https://api.github.com/users/brbrr","html_url":"https://github.com/brbrr","followers_url":"https://api.github.com/users/brbrr/followers","following_url":"https://api.github.com/users/brbrr/following{/other_user}","gists_url":"https://api.github.com/users/brbrr/gists{/gist_id}","starred_url":"https://api.github.com/users/brbrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brbrr/subscriptions","organizations_url":"https://api.github.com/users/brbrr/orgs","repos_url":"https://api.github.com/users/brbrr/repos","events_url":"https://api.github.com/users/brbrr/events{/privacy}","received_events_url":"https://api.github.com/users/brbrr/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1006846081,"node_id":"MDU6TGFiZWwxMDA2ODQ2MDgx","url":"https://api.github.com/repos/Automattic/ghactivity/labels/needs%20review","name":"needs review","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Automattic/ghactivity/pulls/29/commits","review_comments_url":"https://api.github.com/repos/Automattic/ghactivity/pulls/29/comments","review_comment_url":"https://api.github.com/repos/Automattic/ghactivity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/ghactivity/issues/29/comments","statuses_url":"https://api.github.com/repos/Automattic/ghactivity/statuses/3af876c3e086ba9d55ad0c3bc71efb1bb56ce090","head":{"label":"Automattic:add/repo-label-state-backend","ref":"add/repo-label-state-backend","sha":"3af876c3e086ba9d55ad0c3bc71efb1bb56ce090","user":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":53943812,"node_id":"MDEwOlJlcG9zaXRvcnk1Mzk0MzgxMg==","name":"ghactivity","full_name":"Automattic/ghactivity","private":false,"owner":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Automattic/ghactivity","description":"WordPress plugin. Build reports of all your GitHub activity.","fork":false,"url":"https://api.github.com/repos/Automattic/ghactivity","forks_url":"https://api.github.com/repos/Automattic/ghactivity/forks","keys_url":"https://api.github.com/repos/Automattic/ghactivity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/ghactivity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/ghactivity/teams","hooks_url":"https://api.github.com/repos/Automattic/ghactivity/hooks","issue_events_url":"https://api.github.com/repos/Automattic/ghactivity/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/ghactivity/events","assignees_url":"https://api.github.com/repos/Automattic/ghactivity/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/ghactivity/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/ghactivity/tags","blobs_url":"https://api.github.com/repos/Automattic/ghactivity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/ghactivity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/ghactivity/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/ghactivity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/ghactivity/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/ghactivity/languages","stargazers_url":"https://api.github.com/repos/Automattic/ghactivity/stargazers","contributors_url":"https://api.github.com/repos/Automattic/ghactivity/contributors","subscribers_url":"https://api.github.com/repos/Automattic/ghactivity/subscribers","subscription_url":"https://api.github.com/repos/Automattic/ghactivity/subscription","commits_url":"https://api.github.com/repos/Automattic/ghactivity/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/ghactivity/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/ghactivity/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/ghactivity/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/ghactivity/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/ghactivity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/ghactivity/merges","archive_url":"https://api.github.com/repos/Automattic/ghactivity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/ghactivity/downloads","issues_url":"https://api.github.com/repos/Automattic/ghactivity/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/ghactivity/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/ghactivity/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/ghactivity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/ghactivity/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/ghactivity/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/ghactivity/deployments","created_at":"2016-03-15T12:44:54Z","updated_at":"2018-11-07T12:24:11Z","pushed_at":"2018-11-08T19:41:29Z","git_url":"git://github.com/Automattic/ghactivity.git","ssh_url":"git@github.com:Automattic/ghactivity.git","clone_url":"https://github.com/Automattic/ghactivity.git","svn_url":"https://github.com/Automattic/ghactivity","homepage":"https://wordpress.org/plugins/ghactivity/","size":1521,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":9,"license":null,"forks":1,"open_issues":9,"watchers":2,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"bb3d88d08e891c91d511b364bf47f2ad77a23f90","user":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":53943812,"node_id":"MDEwOlJlcG9zaXRvcnk1Mzk0MzgxMg==","name":"ghactivity","full_name":"Automattic/ghactivity","private":false,"owner":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Automattic/ghactivity","description":"WordPress plugin. Build reports of all your GitHub activity.","fork":false,"url":"https://api.github.com/repos/Automattic/ghactivity","forks_url":"https://api.github.com/repos/Automattic/ghactivity/forks","keys_url":"https://api.github.com/repos/Automattic/ghactivity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/ghactivity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/ghactivity/teams","hooks_url":"https://api.github.com/repos/Automattic/ghactivity/hooks","issue_events_url":"https://api.github.com/repos/Automattic/ghactivity/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/ghactivity/events","assignees_url":"https://api.github.com/repos/Automattic/ghactivity/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/ghactivity/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/ghactivity/tags","blobs_url":"https://api.github.com/repos/Automattic/ghactivity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/ghactivity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/ghactivity/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/ghactivity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/ghactivity/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/ghactivity/languages","stargazers_url":"https://api.github.com/repos/Automattic/ghactivity/stargazers","contributors_url":"https://api.github.com/repos/Automattic/ghactivity/contributors","subscribers_url":"https://api.github.com/repos/Automattic/ghactivity/subscribers","subscription_url":"https://api.github.com/repos/Automattic/ghactivity/subscription","commits_url":"https://api.github.com/repos/Automattic/ghactivity/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/ghactivity/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/ghactivity/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/ghactivity/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/ghactivity/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/ghactivity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/ghactivity/merges","archive_url":"https://api.github.com/repos/Automattic/ghactivity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/ghactivity/downloads","issues_url":"https://api.github.com/repos/Automattic/ghactivity/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/ghactivity/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/ghactivity/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/ghactivity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/ghactivity/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/ghactivity/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/ghactivity/deployments","created_at":"2016-03-15T12:44:54Z","updated_at":"2018-11-07T12:24:11Z","pushed_at":"2018-11-08T19:41:29Z","git_url":"git://github.com/Automattic/ghactivity.git","ssh_url":"git@github.com:Automattic/ghactivity.git","clone_url":"https://github.com/Automattic/ghactivity.git","svn_url":"https://github.com/Automattic/ghactivity","homepage":"https://wordpress.org/plugins/ghactivity/","size":1521,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":9,"license":null,"forks":1,"open_issues":9,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/ghactivity/pulls/29"},"html":{"href":"https://github.com/Automattic/ghactivity/pull/29"},"issue":{"href":"https://api.github.com/repos/Automattic/ghactivity/issues/29"},"comments":{"href":"https://api.github.com/repos/Automattic/ghactivity/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/ghactivity/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/ghactivity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/ghactivity/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/ghactivity/statuses/3af876c3e086ba9d55ad0c3bc71efb1bb56ce090"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"jeherve"}}