@@ -50,12 +50,12 @@ ${reasons}
50
50
}
51
51
52
52
class Check {
53
- constructor ( func , reason ) {
54
- this . func = func ;
53
+ constructor ( { predicate , reason } ) {
54
+ this . predicate = predicate ;
55
55
this . reason = reason ;
56
56
}
57
57
58
- evaluate ( ) { return this . func ( ) ; }
58
+ evaluate ( ) { return this . predicate ( ) ; }
59
59
}
60
60
61
61
module . exports = async ( { github, context, core } ) => {
@@ -86,8 +86,8 @@ module.exports = async ({ github, context, core }) => {
86
86
const is_author_only_contribution_on_GH = ( async ( ) => {
87
87
// WARNING: Depending on the time of day, event latency can be anywhere from 30s to 6h. (source: https://octokit.github.io/rest.js/v21/)
88
88
const { data : events } = await github . rest . activity . listEventsForAuthenticatedUser ( {
89
- username : author
90
- // per_page: 1
89
+ username : author ,
90
+ per_page : 1
91
91
} ) ;
92
92
93
93
console . log ( ">>> is_author_only_contribution_on_GH: " , {
@@ -99,15 +99,14 @@ module.exports = async ({ github, context, core }) => {
99
99
return events . length === 0 ;
100
100
} ) ( ) ;
101
101
102
- console . log ( ">>> context.payload:" , context . payload )
103
-
104
102
const checks = [
105
- new Check ( ( ) => was_author_account_recently_created , "Account is less than an hour old" ) ,
106
- new Check ( ( ) => is_author_only_contribution_on_GH , "First contribution to any GitHub project" ) ,
107
- new Check ( ( ) => user . followers === 0 && user . following === 0 , "Author has no relationships" ) ,
108
- new Check ( ( ) => user . public_repos === 0 && user . public_gists === 0 , "Author has no public reop/gist" ) ,
103
+ new Check ( { predicate : was_author_account_recently_created , reason : "Account is less than an hour old" } ) ,
104
+ new Check ( { predicate : is_author_only_contribution_on_GH , reason : "First contribution to any GitHub project" } ) ,
105
+ new Check ( { predicate : ( ) => user . followers === 0 && user . following === 0 , reason : "Author has no relationships" } ) ,
106
+ new Check ( { predicate : ( ) => user . public_repos === 0 && user . public_gists === 0 , reason : "Author has no public reop/gist" } ) ,
109
107
] ;
110
108
109
+ // IDEA: use weight instead of booleans
111
110
const failed_checks = checks . filter ( check => check . evaluate ( ) ) ;
112
111
113
112
const threshold = 0 ;
0 commit comments