-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Needs review] Feature: @rfcbot poll [teams] #219
Conversation
Should probably also fix the individual dashboard to display polls which are awaiting a |
@@ -32,6 +32,7 @@ extern crate url; | |||
extern crate urlencoded; | |||
#[macro_use] | |||
extern crate maplit; | |||
extern crate itertools; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
README.md
Outdated
"poll" | "polled" | "polling" | "polls" | | ||
"query" | "queried" | "querying" | "queries" | | ||
"inquire" | "inquired" | "inquiring" | "inquires" | | ||
"quiz" | "quized" | "quizing" | "quizzes" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quizzed
and quizzing
FWIW
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops :P
src/github/command.rs
Outdated
ResolveConcern(&'a str), | ||
FeedbackRequest(&'a str), | ||
AskQuestion { | ||
teams: BTreeSet<&'a str>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this contain Team
structs instead of strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... That would add some additional unnecessary allocation. And this is really the TeamLabel
(would still require allocation), which isn't inside the Team
struct.
src/github/command.rs
Outdated
pub fn from_str_all(command: &'a str) -> impl Iterator<Item = RfcBotCommand<'a>> { | ||
// Get the tokens for each command line (starts with a bot mention) | ||
command.lines() | ||
.filter(|&l| l.starts_with(RFC_BOT_MENTION)) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/github/command.rs
Outdated
}) | ||
} | ||
|
||
fn from_invocation_line<'a>(command: &'a str) -> DashResult<RfcBotCommand<'a>> { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
command[name_start..].trim() | ||
} | ||
|
||
fn strip_prefix<'h>(haystack: &'h str, prefix: &str) -> &'h str { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/github/command.rs
Outdated
|
||
fn match_team_candidate(team_candidate: &str) -> Option<&'static TeamLabel> { | ||
#[cfg(not(test))] | ||
let setup = &*teams::SETUP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move this conditional compilation into teams.rs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe make it a feature so we can still run tests against the config on disk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't super happy about this mechanism, so that sounds great. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and removed global state instead; much cleaner!
src/github/command.rs
Outdated
let setup = &*teams::test::TEST_SETUP; | ||
|
||
setup.teams().find(|&(label, team)| { | ||
strip_prefix(&label.0, "T-") == strip_prefix(team_candidate, "T-") || |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/github/command.rs
Outdated
|
||
let mut question = parse_command_text(command, subcommand); | ||
let mut teams = BTreeSet::new(); | ||
while let Some(team_candidate) = question.split_whitespace().next() { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/github/command.rs
Outdated
|
||
let mut question = parse_command_text(command, subcommand); | ||
let mut teams = BTreeSet::new(); | ||
while let Some(team_candidate) = question.split_whitespace().next() { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Looking this over and it looks mostly good to me. Unfortunately because the large refactoring (command.rs) is in the same commit as the new poll functionality it's a bit difficult to review. Once my various nits are addressed, lets just get it on prod when you'll be around to fix things?
src/github/nag.rs
Outdated
@@ -185,7 +130,147 @@ fn update_proposal_review_status(proposal_id: i32) -> DashResult<()> { | |||
Ok(()) | |||
} | |||
|
|||
fn update_poll_review_status(poll_id: i32) -> DashResult<()> { | |||
let conn = &*DB_POOL.get()?; | |||
// this is an updated comment from the bot itself |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is?
src/github/nag.rs
Outdated
@@ -185,7 +130,147 @@ fn update_proposal_review_status(proposal_id: i32) -> DashResult<()> { | |||
Ok(()) | |||
} | |||
|
|||
fn update_poll_review_status(poll_id: i32) -> DashResult<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bare numbers in fn args make me a little nervous. Can we separate out the "find the Poll struct from the raw input" and the "update the data model" functionality?
src/github/nag.rs
Outdated
let conn = &*DB_POOL.get()?; | ||
// this is an updated comment from the bot itself | ||
|
||
// parse out each "reviewed" status for each user, then update them |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
src/github/nag.rs
Outdated
|
||
{ | ||
use domain::schema::poll_review_request::dsl::*; | ||
let mut review_request: PollReviewRequest = poll_review_request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling it a PollReviewRequest
seems odd to me in this context -- isn't it more like a PollResponseRequest
or PollRequest
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to PollResponseRequest
.
Ok(()) | ||
} | ||
|
||
fn parse_ticky_boxes<'a>(what: &'a str, id: i32, comment: &'a IssueComment) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
throw!(why) | ||
}); | ||
|
||
for mut survey in pending { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
* update toolchain and lockfile. * add never_type gate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really sweet!
src/github/nag.rs
Outdated
@@ -185,7 +130,147 @@ fn update_proposal_review_status(proposal_id: i32) -> DashResult<()> { | |||
Ok(()) | |||
} | |||
|
|||
fn update_poll_response_status(poll_id: i32) -> DashResult<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seems pretty well scoped to the Poll
type -- what do you think about making it a method and leaving the exact query used to retrieve the Poll
flexible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to punt on larger refactorings now and ship it :)
src/github/nag.rs
Outdated
let conn = &*DB_POOL.get()?; | ||
// this is an updated comment from the bot itself | ||
|
||
// parse out each "responded" status for each user, then update them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still in the right place?
} | ||
|
||
let comment: IssueComment = issuecomment::table | ||
.find(survey.fk_bot_tracking_comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading this code now, I'm wondering whether things like this shouldn't also be impl'd as small methods on the Poll
type to more clearly separate the logic of a poll from its db semantics.
i.e.
let comment: IssueComment = self.tracking_comment()?;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally yes - that would be optimal, but I think this is a larger refactoring that would affect much more code than this PR, so I'd like to punt for now :)
src/github/nag.rs
Outdated
for username in parse_ticky_boxes("poll", survey.id, &comment) { | ||
let user: GitHubUser = githubuser::table | ||
.filter(githubuser::login.eq(username)) | ||
.first(conn)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC this will currently fail the entire poll if someone typo's one of the provided usernames. Do we have an error reporting mechanism for that?
src/github/nag.rs
Outdated
fn evaluate_nags() -> DashResult<()> { | ||
evaluate_pendings()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this now, should we attempt to make progress on all three and combine the errors if more than one fails?
src/github/nag.rs
Outdated
-> DashResult<()> { | ||
use self::RfcBotCommand::*; | ||
match self { | ||
AskQuestion { teams, question } => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a single internal name for questions/polls etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D
This should fix #214 and fix #225 ... hopefully.
I've also refactored a bunch of stuff for readability (less rightward drift, etc.).