@@ -57,44 +57,46 @@ module.exports = async ({ github, context, core }) => {
57
57
58
58
const { data : user } = await github . rest . users . getByUsername ( { username : author } ) ;
59
59
60
- const was_author_account_recently_created = ( ( ) => {
61
-
62
- const time_point = ( ( ) => {
63
- let value = new Date ( ) ;
64
- value . setHours ( value . getHours ( ) - 2 ) ;
65
- return value ;
66
- } ) ;
67
- const create_at = new Date ( user . created_at ) ;
68
-
69
- console . log ( ">>> was_author_account_recently_created: " , {
70
- time_point : time_point ,
71
- create_at : create_at
72
- } ) ;
73
-
74
- return create_at <= time_point ;
75
- } ) ( ) ;
76
-
77
- const is_author_only_contribution_on_GH = ( async ( ) => {
78
- // WARNING: Depending on the time of day, event latency can be anywhere from 30s to 6h. (source: https://octokit.github.io/rest.js/v21/)
79
- const { data : events } = await github . rest . activity . listEventsForAuthenticatedUser ( {
80
- username : author ,
81
- per_page : 1
82
- } ) ;
83
-
84
- console . log ( ">>> is_author_only_contribution_on_GH: " , {
85
- username : author ,
86
- events_length : events . length === 0 ,
87
- events : events
88
- } ) ;
89
-
90
- return events . length === 0 ;
91
- } ) ( ) ;
92
-
93
60
const checks = [
94
- new Check ( { predicate : ( ) => was_author_account_recently_created ( ) , reason : "Account is less than an hour old" } ) ,
95
- new Check ( { predicate : ( ) => is_author_only_contribution_on_GH ( ) , reason : "First contribution to any GitHub project" } ) ,
96
61
new Check ( { predicate : ( ) => user . followers === 0 && user . following === 0 , reason : "Author has no relationships" } ) ,
97
62
new Check ( { predicate : ( ) => user . public_repos === 0 && user . public_gists === 0 , reason : "Author has no public reop/gist" } ) ,
63
+ new Check ( {
64
+ predicate : ( ) => {
65
+
66
+ const time_point = ( ( ) => {
67
+ let value = new Date ( ) ;
68
+ value . setHours ( value . getHours ( ) - 2 ) ;
69
+ return value ;
70
+ } ) ;
71
+ const create_at = new Date ( user . created_at ) ;
72
+
73
+ console . log ( ">>> was_author_account_recently_created: " , {
74
+ time_point : time_point ,
75
+ create_at : create_at
76
+ } ) ;
77
+
78
+ return create_at <= time_point ;
79
+ } ,
80
+ reason : "Account is less than an hour old"
81
+ } ) ,
82
+ new Check ( {
83
+ predicate : async ( ) => {
84
+ // WARNING: Depending on the time of day, event latency can be anywhere from 30s to 6h. (source: https://octokit.github.io/rest.js/v21/)
85
+ const { data : events } = await github . rest . activity . listEventsForAuthenticatedUser ( {
86
+ username : author ,
87
+ per_page : 1
88
+ } ) ;
89
+
90
+ console . log ( ">>> is_author_only_contribution_on_GH: " , {
91
+ username : author ,
92
+ events_length : events . length === 0 ,
93
+ events : events
94
+ } ) ;
95
+
96
+ return events . length === 0 ;
97
+ } ,
98
+ reason : "First contribution to any GitHub project"
99
+ } ) ,
98
100
] ;
99
101
100
102
// IDEA: use weight instead of booleans
0 commit comments