Skip to content

Commit 97a4b26

Browse files
committed
close poll when everyone has answered it.
1 parent fffdbd6 commit 97a4b26

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/github/nag.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn evaluate_polls() -> DashResult<()> {
213213
throw!(why)
214214
});
215215

216-
for survey in pending {
216+
for mut survey in pending {
217217
let initiator = githubuser::table.find(survey.fk_initiator)
218218
.first::<GitHubUser>(conn);
219219
let initiator = ok_or_continue!(initiator, why =>
@@ -224,7 +224,7 @@ fn evaluate_polls() -> DashResult<()> {
224224
let issue = ok_or_continue!(issue, why =>
225225
error!("Unable to retrieve issue for poll {}: {:?}",
226226
survey.id, why));
227-
227+
228228
// check to see if any checkboxes were modified before we end up replacing the comment
229229
ok_or_continue!(update_poll_review_status(survey.id), why =>
230230
error!("Unable to update review status for poll {}: {:?}",
@@ -235,6 +235,15 @@ fn evaluate_polls() -> DashResult<()> {
235235
error!("Unable to retrieve review requests for survey {}: {:?}",
236236
survey.id, why));
237237

238+
// If everyone has answered the poll, close it:
239+
if reviews.iter().all(|(_, review)| review.reviewed) {
240+
survey.poll_closed = true;
241+
let update = diesel::update(poll.find(survey.id))
242+
.set(&survey).execute(conn);
243+
ok_or_continue!(update, why =>
244+
error!("Unable to close poll {}: {:?}", survey.id, why));
245+
}
246+
238247
// update existing status comment with reviews & concerns
239248
let status_comment = RfcBotComment::new(&issue, CommentType::QuestionAsked {
240249
initiator: &initiator,
@@ -722,7 +731,7 @@ fn process_poll
722731
};
723732
let members = specific_subteam_members(|l| teams.contains(&**l))?;
724733

725-
info!("adding a new question to issue.");
734+
info!("adding a new poll to issue.");
726735

727736
// leave github comment stating that question is asked, ping reviewers
728737
let gh_comment = post_insert_comment(issue, CommentType::QuestionAsked {

0 commit comments

Comments
 (0)