Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 4954da8

Browse files
committed
fix: logging for automated checks
1 parent 33c3672 commit 4954da8

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/app/api/system/checks/route.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,38 @@ export async function GET(request, { params }) {
3030
});
3131

3232
// filter out repositories that had checks in the last X hours
33-
let repoStatus = { ignore: [], run: [] };
33+
let repoStatus = { ignore: [], run: [], error: [] };
3434
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({
4056
id: repo.id,
4157
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,
5058
});
5159
}
5260
});
5361

62+
console.log("CHECKS IGNORED", repoStatus.ignore);
63+
console.log("CHECKS ERRORED", repoStatus.error);
64+
5465
// perform checks on these repositories
5566
// use the owners github token (repository->user->account.access_token)
5667
let runs = [];
@@ -94,7 +105,7 @@ export async function GET(request, { params }) {
94105
runs.push({ url: repo.url });
95106
});
96107

97-
console.log(runs);
108+
console.log("CHECKS PERFORMED", runs);
98109

99110
return Response.json(runs);
100111
}

0 commit comments

Comments
 (0)