{"action":"created","comment":{"url":"https://api.github.com/repos/anp/rfcbot-rs/pulls/comments/209422682","pull_request_review_id":145442501,"id":209422682,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTQyMjY4Mg==","diff_hunk":"@@ -185,7 +130,147 @@ fn update_proposal_review_status(proposal_id: i32) -> DashResult<()> {\n     Ok(())\n }\n \n+fn update_poll_review_status(poll_id: i32) -> DashResult<()> {\n+    let conn = &*DB_POOL.get()?;\n+    // this is an updated comment from the bot itself\n+\n+    // parse out each \"reviewed\" status for each user, then update them\n+\n+    let survey: Poll = poll::table.find(poll_id).first(conn)?;\n+\n+    // don't update any statuses if the poll is closed\n+    if survey.poll_closed {\n+        return Ok(());\n+    }\n+\n+    let comment: IssueComment = issuecomment::table\n+        .find(survey.fk_bot_tracking_comment)\n+        .first(conn)?;\n+\n+    // parse the status comment and mark any new reviews as reviewed\n+    for username in parse_ticky_boxes(\"poll\", survey.id, &comment) {\n+        let user: GitHubUser = githubuser::table\n+            .filter(githubuser::login.eq(username))\n+            .first(conn)?;\n+\n+        {\n+            use domain::schema::poll_review_request::dsl::*;\n+            let mut review_request: PollReviewRequest = poll_review_request\n+                .filter(fk_poll.eq(survey.id))\n+                .filter(fk_reviewer.eq(user.id))\n+                .first(conn)?;\n+\n+            review_request.reviewed = true;\n+            diesel::update(poll_review_request.find(review_request.id))\n+                .set(&review_request)\n+                .execute(conn)?;\n+        }\n+    }\n+\n+    Ok(())\n+}\n+\n+fn parse_ticky_boxes<'a>(what: &'a str, id: i32, comment: &'a IssueComment)\n+    -> impl Iterator<Item = &'a str>\n+{\n+    comment.body.lines().filter_map(move |line| if line.starts_with(\"* [\") {\n+        let l = line.trim_left_matches(\"* [\");\n+        let reviewed = l.starts_with('x');\n+        let remaining = l.trim_left_matches(\"x] @\").trim_left_matches(\" ] @\");\n+\n+        if let Some(username) = remaining.split_whitespace().next() {\n+            trace!(\"reviewer parsed as reviewed? {} (line: \\\"{}\\\")\",\n+                    reviewed, l);\n+\n+            if reviewed { Some(username) } else { None }\n+        } else {\n+            warn!(\"An empty usename showed up in comment {} for {} {}\",\n+                  comment.id, what, id);\n+            None\n+        }\n+    } else {\n+        None\n+    })\n+}\n+\n fn evaluate_nags() -> DashResult<()> {\n+    evaluate_pendings()?;\n+    evaluate_ffcps()?;\n+    evaluate_polls()?;\n+    Ok(())\n+}\n+\n+fn evaluate_polls() -> DashResult<()> {\n+    use domain::schema::poll::dsl::*;\n+    use domain::schema::issuecomment::dsl::*;\n+    use domain::schema::issuecomment::dsl::id as issuecomment_id;\n+    let conn = &*DB_POOL.get()?;\n+\n+    // first process all \"pending\" polls (unreviewed)\n+    let pending = poll.filter(poll_closed.eq(false)).load::<Poll>(conn);\n+    let pending = ok_or!(pending, why => {\n+        error!(\"Unable to retrieve list of pending polls: {:?}\", why);\n+        throw!(why)\n+    });\n+\n+    for mut survey in pending {","path":"src/github/nag.rs","position":190,"original_position":181,"commit_id":"9a7a94ac2044cae939d48a0442449883f1959d01","original_commit_id":"97a4b2653984b30973ded29aadd4e15e3585a8e7","user":{"login":"Centril","id":855702,"node_id":"MDQ6VXNlcjg1NTcwMg==","avatar_url":"https://avatars2.githubusercontent.com/u/855702?v=4","gravatar_id":"","url":"https://api.github.com/users/Centril","html_url":"https://github.com/Centril","followers_url":"https://api.github.com/users/Centril/followers","following_url":"https://api.github.com/users/Centril/following{/other_user}","gists_url":"https://api.github.com/users/Centril/gists{/gist_id}","starred_url":"https://api.github.com/users/Centril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Centril/subscriptions","organizations_url":"https://api.github.com/users/Centril/orgs","repos_url":"https://api.github.com/users/Centril/repos","events_url":"https://api.github.com/users/Centril/events{/privacy}","received_events_url":"https://api.github.com/users/Centril/received_events","type":"User","site_admin":false},"body":"So the reason I picked a synonym is that the identifier `poll` is already in scope, so you get an error if you use `poll`. :)","created_at":"2018-08-11T10:01:06Z","updated_at":"2018-08-11T10:01:07Z","html_url":"https://github.com/anp/rfcbot-rs/pull/219#discussion_r209422682","pull_request_url":"https://api.github.com/repos/anp/rfcbot-rs/pulls/219","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/anp/rfcbot-rs/pulls/comments/209422682"},"html":{"href":"https://github.com/anp/rfcbot-rs/pull/219#discussion_r209422682"},"pull_request":{"href":"https://api.github.com/repos/anp/rfcbot-rs/pulls/219"}},"in_reply_to_id":197243690},"pull_request":{"url":"https://api.github.com/repos/anp/rfcbot-rs/pulls/219","id":196085570,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2MDg1NTcw","html_url":"https://github.com/anp/rfcbot-rs/pull/219","diff_url":"https://github.com/anp/rfcbot-rs/pull/219.diff","patch_url":"https://github.com/anp/rfcbot-rs/pull/219.patch","issue_url":"https://api.github.com/repos/anp/rfcbot-rs/issues/219","number":219,"state":"open","locked":false,"title":"[Needs review] Feature: @rfcbot poll [teams]","user":{"login":"Centril","id":855702,"node_id":"MDQ6VXNlcjg1NTcwMg==","avatar_url":"https://avatars2.githubusercontent.com/u/855702?v=4","gravatar_id":"","url":"https://api.github.com/users/Centril","html_url":"https://github.com/Centril","followers_url":"https://api.github.com/users/Centril/followers","following_url":"https://api.github.com/users/Centril/following{/other_user}","gists_url":"https://api.github.com/users/Centril/gists{/gist_id}","starred_url":"https://api.github.com/users/Centril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Centril/subscriptions","organizations_url":"https://api.github.com/users/Centril/orgs","repos_url":"https://api.github.com/users/Centril/repos","events_url":"https://api.github.com/users/Centril/events{/privacy}","received_events_url":"https://api.github.com/users/Centril/received_events","type":"User","site_admin":false},"body":"This should fix #214... hopefully.\r\n\r\nI've also refactored a bunch of stuff for readability (less rightward drift, etc.).","created_at":"2018-06-20T10:05:14Z","updated_at":"2018-08-11T10:01:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c847599b91f2d4c315bc1f32ba10fe449d00d53","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":357639132,"node_id":"MDU6TGFiZWwzNTc2MzkxMzI=","url":"https://api.github.com/repos/anp/rfcbot-rs/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/anp/rfcbot-rs/pulls/219/commits","review_comments_url":"https://api.github.com/repos/anp/rfcbot-rs/pulls/219/comments","review_comment_url":"https://api.github.com/repos/anp/rfcbot-rs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/anp/rfcbot-rs/issues/219/comments","statuses_url":"https://api.github.com/repos/anp/rfcbot-rs/statuses/9a7a94ac2044cae939d48a0442449883f1959d01","head":{"label":"Centril:feature/poll-team-2","ref":"feature/poll-team-2","sha":"9a7a94ac2044cae939d48a0442449883f1959d01","user":{"login":"Centril","id":855702,"node_id":"MDQ6VXNlcjg1NTcwMg==","avatar_url":"https://avatars2.githubusercontent.com/u/855702?v=4","gravatar_id":"","url":"https://api.github.com/users/Centril","html_url":"https://github.com/Centril","followers_url":"https://api.github.com/users/Centril/followers","following_url":"https://api.github.com/users/Centril/following{/other_user}","gists_url":"https://api.github.com/users/Centril/gists{/gist_id}","starred_url":"https://api.github.com/users/Centril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Centril/subscriptions","organizations_url":"https://api.github.com/users/Centril/orgs","repos_url":"https://api.github.com/users/Centril/repos","events_url":"https://api.github.com/users/Centril/events{/privacy}","received_events_url":"https://api.github.com/users/Centril/received_events","type":"User","site_admin":false},"repo":{"id":130275799,"node_id":"MDEwOlJlcG9zaXRvcnkxMzAyNzU3OTk=","name":"rfcbot-rs","full_name":"Centril/rfcbot-rs","owner":{"login":"Centril","id":855702,"node_id":"MDQ6VXNlcjg1NTcwMg==","avatar_url":"https://avatars2.githubusercontent.com/u/855702?v=4","gravatar_id":"","url":"https://api.github.com/users/Centril","html_url":"https://github.com/Centril","followers_url":"https://api.github.com/users/Centril/followers","following_url":"https://api.github.com/users/Centril/following{/other_user}","gists_url":"https://api.github.com/users/Centril/gists{/gist_id}","starred_url":"https://api.github.com/users/Centril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Centril/subscriptions","organizations_url":"https://api.github.com/users/Centril/orgs","repos_url":"https://api.github.com/users/Centril/repos","events_url":"https://api.github.com/users/Centril/events{/privacy}","received_events_url":"https://api.github.com/users/Centril/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Centril/rfcbot-rs","description":null,"fork":true,"url":"https://api.github.com/repos/Centril/rfcbot-rs","forks_url":"https://api.github.com/repos/Centril/rfcbot-rs/forks","keys_url":"https://api.github.com/repos/Centril/rfcbot-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Centril/rfcbot-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Centril/rfcbot-rs/teams","hooks_url":"https://api.github.com/repos/Centril/rfcbot-rs/hooks","issue_events_url":"https://api.github.com/repos/Centril/rfcbot-rs/issues/events{/number}","events_url":"https://api.github.com/repos/Centril/rfcbot-rs/events","assignees_url":"https://api.github.com/repos/Centril/rfcbot-rs/assignees{/user}","branches_url":"https://api.github.com/repos/Centril/rfcbot-rs/branches{/branch}","tags_url":"https://api.github.com/repos/Centril/rfcbot-rs/tags","blobs_url":"https://api.github.com/repos/Centril/rfcbot-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Centril/rfcbot-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Centril/rfcbot-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/Centril/rfcbot-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Centril/rfcbot-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/Centril/rfcbot-rs/languages","stargazers_url":"https://api.github.com/repos/Centril/rfcbot-rs/stargazers","contributors_url":"https://api.github.com/repos/Centril/rfcbot-rs/contributors","subscribers_url":"https://api.github.com/repos/Centril/rfcbot-rs/subscribers","subscription_url":"https://api.github.com/repos/Centril/rfcbot-rs/subscription","commits_url":"https://api.github.com/repos/Centril/rfcbot-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/Centril/rfcbot-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/Centril/rfcbot-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/Centril/rfcbot-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/Centril/rfcbot-rs/contents/{+path}","compare_url":"https://api.github.com/repos/Centril/rfcbot-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Centril/rfcbot-rs/merges","archive_url":"https://api.github.com/repos/Centril/rfcbot-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Centril/rfcbot-rs/downloads","issues_url":"https://api.github.com/repos/Centril/rfcbot-rs/issues{/number}","pulls_url":"https://api.github.com/repos/Centril/rfcbot-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/Centril/rfcbot-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/Centril/rfcbot-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Centril/rfcbot-rs/labels{/name}","releases_url":"https://api.github.com/repos/Centril/rfcbot-rs/releases{/id}","deployments_url":"https://api.github.com/repos/Centril/rfcbot-rs/deployments","created_at":"2018-04-19T21:44:57Z","updated_at":"2018-06-21T18:18:50Z","pushed_at":"2018-08-11T09:56:09Z","git_url":"git://github.com/Centril/rfcbot-rs.git","ssh_url":"git@github.com:Centril/rfcbot-rs.git","clone_url":"https://github.com/Centril/rfcbot-rs.git","svn_url":"https://github.com/Centril/rfcbot-rs","homepage":"https://rfcbot.rs","size":21776,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"anp:master","ref":"master","sha":"cd54241359cf65742ed5a0fba58ea5114de06f2b","user":{"login":"anp","id":6812281,"node_id":"MDQ6VXNlcjY4MTIyODE=","avatar_url":"https://avatars2.githubusercontent.com/u/6812281?v=4","gravatar_id":"","url":"https://api.github.com/users/anp","html_url":"https://github.com/anp","followers_url":"https://api.github.com/users/anp/followers","following_url":"https://api.github.com/users/anp/following{/other_user}","gists_url":"https://api.github.com/users/anp/gists{/gist_id}","starred_url":"https://api.github.com/users/anp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anp/subscriptions","organizations_url":"https://api.github.com/users/anp/orgs","repos_url":"https://api.github.com/users/anp/repos","events_url":"https://api.github.com/users/anp/events{/privacy}","received_events_url":"https://api.github.com/users/anp/received_events","type":"User","site_admin":false},"repo":{"id":56173786,"node_id":"MDEwOlJlcG9zaXRvcnk1NjE3Mzc4Ng==","name":"rfcbot-rs","full_name":"anp/rfcbot-rs","owner":{"login":"anp","id":6812281,"node_id":"MDQ6VXNlcjY4MTIyODE=","avatar_url":"https://avatars2.githubusercontent.com/u/6812281?v=4","gravatar_id":"","url":"https://api.github.com/users/anp","html_url":"https://github.com/anp","followers_url":"https://api.github.com/users/anp/followers","following_url":"https://api.github.com/users/anp/following{/other_user}","gists_url":"https://api.github.com/users/anp/gists{/gist_id}","starred_url":"https://api.github.com/users/anp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anp/subscriptions","organizations_url":"https://api.github.com/users/anp/orgs","repos_url":"https://api.github.com/users/anp/repos","events_url":"https://api.github.com/users/anp/events{/privacy}","received_events_url":"https://api.github.com/users/anp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/anp/rfcbot-rs","description":null,"fork":false,"url":"https://api.github.com/repos/anp/rfcbot-rs","forks_url":"https://api.github.com/repos/anp/rfcbot-rs/forks","keys_url":"https://api.github.com/repos/anp/rfcbot-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anp/rfcbot-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anp/rfcbot-rs/teams","hooks_url":"https://api.github.com/repos/anp/rfcbot-rs/hooks","issue_events_url":"https://api.github.com/repos/anp/rfcbot-rs/issues/events{/number}","events_url":"https://api.github.com/repos/anp/rfcbot-rs/events","assignees_url":"https://api.github.com/repos/anp/rfcbot-rs/assignees{/user}","branches_url":"https://api.github.com/repos/anp/rfcbot-rs/branches{/branch}","tags_url":"https://api.github.com/repos/anp/rfcbot-rs/tags","blobs_url":"https://api.github.com/repos/anp/rfcbot-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anp/rfcbot-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anp/rfcbot-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/anp/rfcbot-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anp/rfcbot-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/anp/rfcbot-rs/languages","stargazers_url":"https://api.github.com/repos/anp/rfcbot-rs/stargazers","contributors_url":"https://api.github.com/repos/anp/rfcbot-rs/contributors","subscribers_url":"https://api.github.com/repos/anp/rfcbot-rs/subscribers","subscription_url":"https://api.github.com/repos/anp/rfcbot-rs/subscription","commits_url":"https://api.github.com/repos/anp/rfcbot-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/anp/rfcbot-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/anp/rfcbot-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/anp/rfcbot-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/anp/rfcbot-rs/contents/{+path}","compare_url":"https://api.github.com/repos/anp/rfcbot-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anp/rfcbot-rs/merges","archive_url":"https://api.github.com/repos/anp/rfcbot-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anp/rfcbot-rs/downloads","issues_url":"https://api.github.com/repos/anp/rfcbot-rs/issues{/number}","pulls_url":"https://api.github.com/repos/anp/rfcbot-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/anp/rfcbot-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/anp/rfcbot-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anp/rfcbot-rs/labels{/name}","releases_url":"https://api.github.com/repos/anp/rfcbot-rs/releases{/id}","deployments_url":"https://api.github.com/repos/anp/rfcbot-rs/deployments","created_at":"2016-04-13T17:49:34Z","updated_at":"2018-08-11T05:28:04Z","pushed_at":"2018-08-11T09:56:10Z","git_url":"git://github.com/anp/rfcbot-rs.git","ssh_url":"git@github.com:anp/rfcbot-rs.git","clone_url":"https://github.com/anp/rfcbot-rs.git","svn_url":"https://github.com/anp/rfcbot-rs","homepage":"https://rfcbot.rs","size":21730,"stargazers_count":66,"watchers_count":66,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":28,"mirror_url":null,"archived":false,"open_issues_count":31,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":28,"open_issues":31,"watchers":66,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/anp/rfcbot-rs/pulls/219"},"html":{"href":"https://github.com/anp/rfcbot-rs/pull/219"},"issue":{"href":"https://api.github.com/repos/anp/rfcbot-rs/issues/219"},"comments":{"href":"https://api.github.com/repos/anp/rfcbot-rs/issues/219/comments"},"review_comments":{"href":"https://api.github.com/repos/anp/rfcbot-rs/pulls/219/comments"},"review_comment":{"href":"https://api.github.com/repos/anp/rfcbot-rs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/anp/rfcbot-rs/pulls/219/commits"},"statuses":{"href":"https://api.github.com/repos/anp/rfcbot-rs/statuses/9a7a94ac2044cae939d48a0442449883f1959d01"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"Centril"}}