Skip to content

Commit ce8e298

Browse files
authored
[Needs review] Feature: @rfcbot poll [teams] (#219)
* 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.
1 parent cd54241 commit ce8e298

File tree

12 files changed

+1174
-616
lines changed

12 files changed

+1174
-616
lines changed

Cargo.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ toml = "0.4"
2525
url = "1.4"
2626
urlencoded = "0.5"
2727
maplit = "1.0.1"
28+
itertools = "0.7.8"
2829

2930
[dependencies.chrono]
3031
features = ["serde"]

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,25 @@ cancel ::= "cancel | "canceled" | "canceling" | "cancels" ;
5252
review ::= "reviewed" | "review" | "reviewing" | "reviews" ;
5353
concern ::= "concern" | "concerned" | "concerning" | "concerns" ;
5454
resolve ::= "resolve" | "resolved" | "resolving" | "resolves" ;
55+
poll ::= "ask" | "asked" | "asking" | "asks" |
56+
"poll" | "polled" | "polling" | "polls" |
57+
"query" | "queried" | "querying" | "queries" |
58+
"inquire" | "inquired" | "inquiring" | "inquires" |
59+
"quiz" | "quizzed" | "quizzing" | "quizzes" |
60+
"survey" | "surveyed" | "surveying" | "surveys" ;
61+
62+
team_label ::= "T-lang" | .. ;
63+
team_label_simple ::= "lang" | .. ;
64+
team_ping ::= "@"? "rust-lang/lang" | ..;
65+
team_target ::= team_label | team_label_simple | team_ping ;
5566
5667
line_remainder ::= .+$ ;
5768
ws_separated ::= ... ;
5869
5970
subcommand ::= merge | close | postpone | cancel | review
6071
| concern line_remainder
6172
| resolve line_remainder
73+
| poll [team_target]* line_remainder
6274
;
6375
6476
invocation ::= "fcp" subcommand
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DROP TABLE poll;
2+
DROP TABLE poll_response_request;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE TABLE poll (
2+
id SERIAL PRIMARY KEY,
3+
fk_issue INTEGER UNIQUE NOT NULL REFERENCES issue (id),
4+
fk_initiator INTEGER NOT NULL REFERENCES githubuser (id),
5+
fk_initiating_comment INTEGER NOT NULL REFERENCES issuecomment (id),
6+
fk_bot_tracking_comment INTEGER NOT NULL REFERENCES issuecomment (id),
7+
poll_question VARCHAR NOT NULL,
8+
poll_created_at TIMESTAMP NOT NULL,
9+
poll_closed BOOLEAN NOT NULL,
10+
poll_teams VARCHAR NOT NULL
11+
);
12+
13+
CREATE TABLE poll_response_request (
14+
id SERIAL PRIMARY KEY,
15+
fk_poll INTEGER NOT NULL REFERENCES poll (id) ON DELETE CASCADE,
16+
fk_respondent INTEGER NOT NULL REFERENCES githubuser (id),
17+
responded BOOLEAN NOT NULL,
18+
UNIQUE (fk_poll, fk_respondent)
19+
);

src/domain/rfcbot.rs

+46
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@ use chrono::NaiveDateTime;
22

33
use super::schema::*;
44

5+
#[derive(Clone, Debug, Eq, Ord, Insertable, PartialEq, PartialOrd)]
6+
#[table_name="poll"]
7+
pub struct NewPoll<'a> {
8+
pub fk_issue: i32,
9+
pub fk_initiator: i32,
10+
pub fk_initiating_comment: i32,
11+
pub fk_bot_tracking_comment: i32,
12+
pub poll_question: &'a str,
13+
pub poll_created_at: NaiveDateTime,
14+
pub poll_closed: bool,
15+
pub poll_teams: &'a str,
16+
}
17+
18+
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Ord,
19+
PartialEq, PartialOrd, Queryable, Serialize)]
20+
#[table_name="poll"]
21+
pub struct Poll {
22+
pub id: i32,
23+
pub fk_issue: i32,
24+
pub fk_initiator: i32,
25+
pub fk_initiating_comment: i32,
26+
pub fk_bot_tracking_comment: i32,
27+
pub poll_question: String,
28+
pub poll_created_at: NaiveDateTime,
29+
pub poll_closed: bool,
30+
pub poll_teams: String,
31+
}
32+
533
#[derive(Clone, Debug, Eq, Ord, Insertable, PartialEq, PartialOrd)]
634
#[table_name="fcp_proposal"]
735
pub struct NewFcpProposal<'a> {
@@ -14,6 +42,24 @@ pub struct NewFcpProposal<'a> {
1442
pub fcp_closed: bool,
1543
}
1644

45+
#[derive(Clone, Debug, Eq, Insertable, Ord, PartialEq, PartialOrd, Serialize)]
46+
#[table_name="poll_response_request"]
47+
pub struct NewPollResponseRequest {
48+
pub fk_poll: i32,
49+
pub fk_respondent: i32,
50+
pub responded: bool,
51+
}
52+
53+
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Ord,
54+
PartialEq, PartialOrd, Queryable, Serialize)]
55+
#[table_name="poll_response_request"]
56+
pub struct PollResponseRequest {
57+
pub id: i32,
58+
pub fk_poll: i32,
59+
pub fk_respondent: i32,
60+
pub responded: bool,
61+
}
62+
1763
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Ord,
1864
PartialEq, PartialOrd, Queryable, Serialize)]
1965
#[table_name="fcp_proposal"]

src/domain/schema.rs

+27
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,29 @@ table! {
129129
}
130130
}
131131

132+
table! {
133+
poll (id) {
134+
id -> Int4,
135+
fk_issue -> Int4,
136+
fk_initiator -> Int4,
137+
fk_initiating_comment -> Int4,
138+
fk_bot_tracking_comment -> Int4,
139+
poll_question -> Varchar,
140+
poll_created_at -> Timestamp,
141+
poll_closed -> Bool,
142+
poll_teams -> Varchar,
143+
}
144+
}
145+
146+
table! {
147+
poll_response_request (id) {
148+
id -> Int4,
149+
fk_poll -> Int4,
150+
fk_respondent -> Int4,
151+
responded -> Bool,
152+
}
153+
}
154+
132155
joinable!(fcp_concern -> githubuser (fk_initiator));
133156
joinable!(fcp_concern -> fcp_proposal (fk_proposal));
134157
joinable!(fcp_proposal -> githubuser (fk_initiator));
@@ -143,3 +166,7 @@ joinable!(pullrequest -> githubuser (fk_assignee));
143166
joinable!(pullrequest -> milestone (fk_milestone));
144167
joinable!(rfc_feedback_request -> issuecomment (fk_feedback_comment));
145168
joinable!(rfc_feedback_request -> issue (fk_issue));
169+
joinable!(poll -> githubuser (fk_initiator));
170+
joinable!(poll -> issue (fk_issue));
171+
joinable!(poll_response_request -> poll (fk_poll));
172+
joinable!(poll_response_request -> githubuser (fk_respondent));

0 commit comments

Comments
 (0)