@@ -3,7 +3,7 @@ async function when_suspicious({ github, context, failed_checks }){
3
3
// might wanna use a score of confidence (how suspicious it is), then react on that
4
4
5
5
const { owner, repo } = context . repo ;
6
- const issueNumber = context . payload . issue . number ;
6
+ const issueNumber = context . payload . number ; // either issue or PR
7
7
8
8
// await github.rest.issues.addLabels({
9
9
// owner,
@@ -68,17 +68,20 @@ module.exports = async ({ github, context, core }) => {
68
68
69
69
70
70
const was_author_account_recently_created = ( ( ) => {
71
- const createdAt = new Date ( user . created_at ) ;
72
- const now = new Date ( ) ;
73
- const accountAgeInMinutes = ( now - createdAt ) / ( 1000 * 60 ) ;
71
+
72
+ const time_point = ( ( ) => {
73
+ let value = new Date ( ) ;
74
+ value . setHours ( value . getHours ( ) - 2 ) ;
75
+ return value ;
76
+ } ) ;
77
+ const create_at = new Date ( user . created_at ) ;
74
78
75
79
console . log ( ">>> was_author_account_recently_created: " , {
76
- now : now ,
77
- createdAt : createdAt ,
78
- accountAgeInMinutes : accountAgeInMinutes
80
+ time_point : time_point ,
81
+ create_at : create_at
79
82
} ) ;
80
83
81
- return ( accountAgeInMinutes < 60 ) ;
84
+ return create_at >= time_point ;
82
85
} ) ( ) ;
83
86
84
87
const is_author_only_contribution_on_GH = ( async ( ) => {
@@ -105,6 +108,7 @@ module.exports = async ({ github, context, core }) => {
105
108
const failed_checks = checks . filter ( check => ! check . evaluate ( ) ) ;
106
109
107
110
const threshold = 0 ;
111
+ console . log ( ">>> failed_checks amount: " , failed_checks . length , "vs. threshold: " , threshold )
108
112
if ( failed_checks . length <= threshold )
109
113
return ;
110
114
0 commit comments