@@ -30,27 +30,38 @@ export async function GET(request, { params }) {
30
30
} ) ;
31
31
32
32
// filter out repositories that had checks in the last X hours
33
- let repoStatus = { ignore : [ ] , run : [ ] } ;
33
+ let repoStatus = { ignore : [ ] , run : [ ] , error : [ ] } ;
34
34
repos . forEach ( ( repo ) => {
35
- if (
36
- ! repo . checks [ 0 ] ||
37
- differenceInHours ( new Date ( ) , repo . checks [ 0 ] . createdAt ) >= 24 * 7 // TODO: move to Flagsmith
38
- ) {
39
- repoStatus . run . push ( {
35
+ try {
36
+ if (
37
+ ! repo . checks [ 0 ] ||
38
+ differenceInHours ( new Date ( ) , repo . checks [ 0 ] . createdAt ) >= 24 * 7 // TODO: move to Flagsmith
39
+ ) {
40
+ repoStatus . run . push ( {
41
+ id : repo . id ,
42
+ url : repo . url ,
43
+ token : repo . user . accounts [ 0 ] . access_token ,
44
+ lastChecked : repo . checks [ 0 ] . createdAt ,
45
+ } ) ;
46
+ } else {
47
+ repoStatus . ignore . push ( {
48
+ id : repo . id ,
49
+ url : repo . url ,
50
+ lastChecked : repo . checks [ 0 ] . createdAt ,
51
+ } ) ;
52
+ }
53
+ } catch ( e ) {
54
+ console . error ( e ) ;
55
+ repoStatus . error . push ( {
40
56
id : repo . id ,
41
57
url : repo . url ,
42
- token : repo . user . accounts [ 0 ] . access_token ,
43
- lastChecked : repo . checks [ 0 ] . createdAt ,
44
- } ) ;
45
- } else {
46
- repoStatus . ignore . push ( {
47
- id : repo . id ,
48
- url : repo . url ,
49
- lastChecked : repo . checks [ 0 ] . createdAt ,
50
58
} ) ;
51
59
}
52
60
} ) ;
53
61
62
+ console . log ( "CHECKS IGNORED" , repoStatus . ignore ) ;
63
+ console . log ( "CHECKS ERRORED" , repoStatus . error ) ;
64
+
54
65
// perform checks on these repositories
55
66
// use the owners github token (repository->user->account.access_token)
56
67
let runs = [ ] ;
@@ -94,7 +105,7 @@ export async function GET(request, { params }) {
94
105
runs . push ( { url : repo . url } ) ;
95
106
} ) ;
96
107
97
- console . log ( runs ) ;
108
+ console . log ( "CHECKS PERFORMED" , runs ) ;
98
109
99
110
return Response . json ( runs ) ;
100
111
}
0 commit comments