1
1
use diesel:: prelude:: * ;
2
2
3
3
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;
5
6
use crate :: error:: DashResult ;
6
7
use crate :: DB_POOL ;
7
8
8
9
#[ derive( Serialize ) ]
9
10
pub struct FcpWithInfo {
10
11
pub fcp : FcpProposal ,
11
12
pub reviews : Vec < ( GitHubUser , bool ) > ,
13
+ // (Concern name, comment registering it, and user leaving it)
14
+ pub concerns : Vec < ( String , IssueComment , GitHubUser ) > ,
12
15
pub issue : Issue ,
13
16
pub status_comment : IssueComment ,
14
17
}
@@ -31,6 +34,26 @@ pub fn all_fcps() -> DashResult<Vec<FcpWithInfo>> {
31
34
. filter ( fcp_review_request:: fk_proposal. eq ( fcp. id ) )
32
35
. load :: < FcpReviewRequest > ( conn) ?;
33
36
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
+
34
57
let mut reviews_with_users = Vec :: new ( ) ;
35
58
36
59
for review in reviews {
@@ -51,6 +74,7 @@ pub fn all_fcps() -> DashResult<Vec<FcpWithInfo>> {
51
74
let fcp_with_info = FcpWithInfo {
52
75
fcp,
53
76
reviews : reviews_with_users,
77
+ concerns,
54
78
issue,
55
79
status_comment,
56
80
} ;
0 commit comments