Skip to content

Commit

Permalink
[Needs review] Feature: @rfcbot poll [teams] (#219)
Browse files Browse the repository at this point in the history
* add itertools as dependency.

* add database model for Poll stuff.

* really add itertools as dependency in main.rs.

* teams: expose test data, change team names a bit, expose ping and name of teams.

* refactor a bunch of logic and implement polling (hopefully...).

* update command grammar in README.md.

* fix syntax error in up.sql migration.

* fix copy error in up.sql migration.

* fix typo in up.sql migration.

* close poll when everyone has answered it.

* fix #212 by filtering in unstarted fcps. (#223)

* Update toolchain and lockfile (#232)

* update toolchain and lockfile.

* add never_type gate.

* Add Centril to the lang team (#230)

* fix typos (quized -> quizzed).

* fix 225, and deal with leading whitespace.

* colocate from_invocation_line and from_str_all.

* get rid of global state from command parser.

* review -> response for polls.

* fix comments.

* make progress on all 3 in evaluate_nags.

* RfcBotCommand::{AskQuestion -> StartPoll}.

* gracefully handle poll comment typos.

* fix bug.
  • Loading branch information
Centril authored Aug 16, 2018
1 parent cd54241 commit ce8e298
Show file tree
Hide file tree
Showing 12 changed files with 1,174 additions and 616 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ toml = "0.4"
url = "1.4"
urlencoded = "0.5"
maplit = "1.0.1"
itertools = "0.7.8"

[dependencies.chrono]
features = ["serde"]
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,25 @@ cancel ::= "cancel | "canceled" | "canceling" | "cancels" ;
review ::= "reviewed" | "review" | "reviewing" | "reviews" ;
concern ::= "concern" | "concerned" | "concerning" | "concerns" ;
resolve ::= "resolve" | "resolved" | "resolving" | "resolves" ;
poll ::= "ask" | "asked" | "asking" | "asks" |
"poll" | "polled" | "polling" | "polls" |
"query" | "queried" | "querying" | "queries" |
"inquire" | "inquired" | "inquiring" | "inquires" |
"quiz" | "quizzed" | "quizzing" | "quizzes" |
"survey" | "surveyed" | "surveying" | "surveys" ;
team_label ::= "T-lang" | .. ;
team_label_simple ::= "lang" | .. ;
team_ping ::= "@"? "rust-lang/lang" | ..;
team_target ::= team_label | team_label_simple | team_ping ;
line_remainder ::= .+$ ;
ws_separated ::= ... ;
subcommand ::= merge | close | postpone | cancel | review
| concern line_remainder
| resolve line_remainder
| poll [team_target]* line_remainder
;
invocation ::= "fcp" subcommand
Expand Down
2 changes: 2 additions & 0 deletions migrations/2018-06-20-062854_create_poll_table/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP TABLE poll;
DROP TABLE poll_response_request;
19 changes: 19 additions & 0 deletions migrations/2018-06-20-062854_create_poll_table/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE poll (
id SERIAL PRIMARY KEY,
fk_issue INTEGER UNIQUE NOT NULL REFERENCES issue (id),
fk_initiator INTEGER NOT NULL REFERENCES githubuser (id),
fk_initiating_comment INTEGER NOT NULL REFERENCES issuecomment (id),
fk_bot_tracking_comment INTEGER NOT NULL REFERENCES issuecomment (id),
poll_question VARCHAR NOT NULL,
poll_created_at TIMESTAMP NOT NULL,
poll_closed BOOLEAN NOT NULL,
poll_teams VARCHAR NOT NULL
);

CREATE TABLE poll_response_request (
id SERIAL PRIMARY KEY,
fk_poll INTEGER NOT NULL REFERENCES poll (id) ON DELETE CASCADE,
fk_respondent INTEGER NOT NULL REFERENCES githubuser (id),
responded BOOLEAN NOT NULL,
UNIQUE (fk_poll, fk_respondent)
);
46 changes: 46 additions & 0 deletions src/domain/rfcbot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@ use chrono::NaiveDateTime;

use super::schema::*;

#[derive(Clone, Debug, Eq, Ord, Insertable, PartialEq, PartialOrd)]
#[table_name="poll"]
pub struct NewPoll<'a> {
pub fk_issue: i32,
pub fk_initiator: i32,
pub fk_initiating_comment: i32,
pub fk_bot_tracking_comment: i32,
pub poll_question: &'a str,
pub poll_created_at: NaiveDateTime,
pub poll_closed: bool,
pub poll_teams: &'a str,
}

#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Ord,
PartialEq, PartialOrd, Queryable, Serialize)]
#[table_name="poll"]
pub struct Poll {
pub id: i32,
pub fk_issue: i32,
pub fk_initiator: i32,
pub fk_initiating_comment: i32,
pub fk_bot_tracking_comment: i32,
pub poll_question: String,
pub poll_created_at: NaiveDateTime,
pub poll_closed: bool,
pub poll_teams: String,
}

#[derive(Clone, Debug, Eq, Ord, Insertable, PartialEq, PartialOrd)]
#[table_name="fcp_proposal"]
pub struct NewFcpProposal<'a> {
Expand All @@ -14,6 +42,24 @@ pub struct NewFcpProposal<'a> {
pub fcp_closed: bool,
}

#[derive(Clone, Debug, Eq, Insertable, Ord, PartialEq, PartialOrd, Serialize)]
#[table_name="poll_response_request"]
pub struct NewPollResponseRequest {
pub fk_poll: i32,
pub fk_respondent: i32,
pub responded: bool,
}

#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Ord,
PartialEq, PartialOrd, Queryable, Serialize)]
#[table_name="poll_response_request"]
pub struct PollResponseRequest {
pub id: i32,
pub fk_poll: i32,
pub fk_respondent: i32,
pub responded: bool,
}

#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Ord,
PartialEq, PartialOrd, Queryable, Serialize)]
#[table_name="fcp_proposal"]
Expand Down
27 changes: 27 additions & 0 deletions src/domain/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,29 @@ table! {
}
}

table! {
poll (id) {
id -> Int4,
fk_issue -> Int4,
fk_initiator -> Int4,
fk_initiating_comment -> Int4,
fk_bot_tracking_comment -> Int4,
poll_question -> Varchar,
poll_created_at -> Timestamp,
poll_closed -> Bool,
poll_teams -> Varchar,
}
}

table! {
poll_response_request (id) {
id -> Int4,
fk_poll -> Int4,
fk_respondent -> Int4,
responded -> Bool,
}
}

joinable!(fcp_concern -> githubuser (fk_initiator));
joinable!(fcp_concern -> fcp_proposal (fk_proposal));
joinable!(fcp_proposal -> githubuser (fk_initiator));
Expand All @@ -143,3 +166,7 @@ joinable!(pullrequest -> githubuser (fk_assignee));
joinable!(pullrequest -> milestone (fk_milestone));
joinable!(rfc_feedback_request -> issuecomment (fk_feedback_comment));
joinable!(rfc_feedback_request -> issue (fk_issue));
joinable!(poll -> githubuser (fk_initiator));
joinable!(poll -> issue (fk_issue));
joinable!(poll_response_request -> poll (fk_poll));
joinable!(poll_response_request -> githubuser (fk_respondent));
Loading

0 comments on commit ce8e298

Please sign in to comment.