@@ -13,6 +13,8 @@ function identifyAge(date) {
13
13
}
14
14
}
15
15
16
+ const apiPrefix = "https://github-issue-proxy.illicitonion.com/cached/2/repos/CodeYourFuture/" ;
17
+
16
18
// TODO: Pull these in from config.
17
19
export const modules = [
18
20
"Module-User-Focused-Data" ,
@@ -33,7 +35,35 @@ class PR {
33
35
this . createdAge = createdAge ;
34
36
this . updatedAge = updatedAge ;
35
37
this . status = status ;
36
- this . comments = [ ] ;
38
+ this . _didLoadReviews = false ;
39
+ this . reviews = [ ] ;
40
+ }
41
+
42
+ async loadReviews ( ) {
43
+ if ( this . _didLoadReviews ) {
44
+ return ;
45
+ }
46
+ const response = await fetch ( `${ apiPrefix } /${ this . module } /pulls/${ this . number } /reviews` ) ;
47
+ const reviews = await response . json ( ) ;
48
+ for ( const reviewResponse of reviews ) {
49
+ const review = new Review ( reviewResponse . user . login , reviewResponse . user . login === this . userName , identifyAge ( new Date ( Date . parse ( reviewResponse [ "submitted_at" ] ) ) ) , reviewResponse . state ) ;
50
+ this . reviews . push ( review ) ;
51
+ }
52
+ this . _didLoadReviews = true ;
53
+ }
54
+
55
+ hasReviewer ( ) {
56
+ return this . reviews . some ( review => ! review . isPrAuthor ) ;
57
+ }
58
+ }
59
+
60
+ class Review {
61
+ constructor ( userName , isPrAuthor , age , state ) {
62
+ this . userName = userName ;
63
+ this . isPrAuthor = isPrAuthor ;
64
+ this . age = age ;
65
+ // e.g. "COMMENTED".
66
+ this . state = state ;
37
67
}
38
68
}
39
69
@@ -58,11 +88,11 @@ function getStatus(state, labels) {
58
88
return "Unknown" ;
59
89
}
60
90
61
- export async function fetchPrs ( ) {
91
+ export async function fetchPrsWithoutLoadingReviews ( ) {
62
92
const prs = [ ] ;
63
93
const responsePromises = [ ] ;
64
94
for ( const module of modules ) {
65
- responsePromises . push ( fetch ( `https://github-issue-proxy.illicitonion.com/cached/2/repos/CodeYourFuture /${ module } /pulls?state=all` ) . then ( ( response ) => response . json ( ) ) ) ;
95
+ responsePromises . push ( fetch ( `${ apiPrefix } /${ module } /pulls?state=all` ) . then ( ( response ) => response . json ( ) ) ) ;
66
96
}
67
97
const responsesByModule = await Promise . all ( responsePromises ) ;
68
98
for ( let i = 0 ; i < responsesByModule . length ; i ++ ) {
0 commit comments