Skip to content

Commit 8d2e1f6

Browse files
Render pending concerns on dashboard
1 parent 850b642 commit 8d2e1f6

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

src/nag.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
use diesel::prelude::*;
22

33
use crate::domain::github::{GitHubUser, Issue, IssueComment};
4-
use crate::domain::rfcbot::{FcpProposal, FcpReviewRequest};
4+
use crate::domain::rfcbot::{FcpConcern, FcpProposal, FcpReviewRequest};
5+
use crate::domain::schema::fcp_concern;
56
use crate::error::DashResult;
67
use crate::DB_POOL;
78

89
#[derive(Serialize)]
910
pub struct FcpWithInfo {
1011
pub fcp: FcpProposal,
1112
pub reviews: Vec<(GitHubUser, bool)>,
13+
// (Concern name, comment registering it, and user leaving it)
14+
pub concerns: Vec<(String, IssueComment, GitHubUser)>,
1215
pub issue: Issue,
1316
pub status_comment: IssueComment,
1417
}
@@ -31,6 +34,26 @@ pub fn all_fcps() -> DashResult<Vec<FcpWithInfo>> {
3134
.filter(fcp_review_request::fk_proposal.eq(fcp.id))
3235
.load::<FcpReviewRequest>(conn)?;
3336

37+
let raw_concerns = fcp_concern::table
38+
.filter(fcp_concern::fk_proposal.eq(fcp.id))
39+
.load::<FcpConcern>(conn)?;
40+
41+
let mut concerns = Vec::new();
42+
43+
for concern in raw_concerns {
44+
// Skip resolved concerns.
45+
if concern.fk_resolved_comment.is_some() {
46+
continue;
47+
}
48+
let user = githubuser::table
49+
.filter(githubuser::id.eq(concern.fk_initiator))
50+
.first(conn)?;
51+
let comment = issuecomment::table
52+
.filter(issuecomment::id.eq(concern.fk_initiating_comment))
53+
.first::<IssueComment>(conn)?;
54+
concerns.push((concern.name, comment, user));
55+
}
56+
3457
let mut reviews_with_users = Vec::new();
3558

3659
for review in reviews {
@@ -51,6 +74,7 @@ pub fn all_fcps() -> DashResult<Vec<FcpWithInfo>> {
5174
let fcp_with_info = FcpWithInfo {
5275
fcp,
5376
reviews: reviews_with_users,
77+
concerns,
5478
issue,
5579
status_comment,
5680
};

src/server.rs

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ mod html {
4545
let nag::FcpWithInfo {
4646
fcp,
4747
reviews,
48+
mut concerns,
4849
issue,
4950
status_comment,
5051
} = fcp;
@@ -57,11 +58,14 @@ mod html {
5758

5859
pending_reviewers.sort();
5960

61+
concerns.sort_by_key(|c| c.0.clone());
62+
6063
let record = json!({
6164
"disposition": fcp.disposition,
6265
"issue": issue,
6366
"statusComment": status_comment,
6467
"pendingReviewers": pending_reviewers,
68+
"pendingConcerns": concerns,
6569
});
6670

6771
for label in issue.labels.iter().filter(|l| l.starts_with("T-")).cloned() {

src/templates/fcp.hbs

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@
1414
{{#each fcp.pendingReviewers as |r| }}
1515
<a href="/fcp/{{r}}">{{ r }}</a>&nbsp;
1616
{{else}}
17-
pending concerns
17+
no pending checkboxes
18+
{{/each}}
19+
</li></ul>
20+
21+
<ul><li>
22+
{{#each fcp.pendingConcerns as |r| }}
23+
<a href="https://github.com/{{ fcp.issue.repository }}/issues/{{ fcp.issue.number }}#issuecomment-{{ r.[1].id }}">{{ r.[0] }} (by {{ r.[2].login }})</a>&nbsp;
24+
{{else}}
25+
no pending concerns
1826
{{/each}}
1927
</li></ul>
2028
</li>

0 commit comments

Comments
 (0)