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

Commit

Permalink
fix: logging for automated checks
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Sep 11, 2024
1 parent 33c3672 commit 4954da8
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/app/api/system/checks/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,38 @@ export async function GET(request, { params }) {
});

// filter out repositories that had checks in the last X hours
let repoStatus = { ignore: [], run: [] };
let repoStatus = { ignore: [], run: [], error: [] };
repos.forEach((repo) => {
if (
!repo.checks[0] ||
differenceInHours(new Date(), repo.checks[0].createdAt) >= 24 * 7 // TODO: move to Flagsmith
) {
repoStatus.run.push({
try {
if (
!repo.checks[0] ||
differenceInHours(new Date(), repo.checks[0].createdAt) >= 24 * 7 // TODO: move to Flagsmith
) {
repoStatus.run.push({
id: repo.id,
url: repo.url,
token: repo.user.accounts[0].access_token,
lastChecked: repo.checks[0].createdAt,
});
} else {
repoStatus.ignore.push({
id: repo.id,
url: repo.url,
lastChecked: repo.checks[0].createdAt,
});
}
} catch (e) {
console.error(e);
repoStatus.error.push({
id: repo.id,
url: repo.url,
token: repo.user.accounts[0].access_token,
lastChecked: repo.checks[0].createdAt,
});
} else {
repoStatus.ignore.push({
id: repo.id,
url: repo.url,
lastChecked: repo.checks[0].createdAt,
});
}
});

console.log("CHECKS IGNORED", repoStatus.ignore);
console.log("CHECKS ERRORED", repoStatus.error);

// perform checks on these repositories
// use the owners github token (repository->user->account.access_token)
let runs = [];
Expand Down Expand Up @@ -94,7 +105,7 @@ export async function GET(request, { params }) {
runs.push({ url: repo.url });
});

console.log(runs);
console.log("CHECKS PERFORMED", runs);

return Response.json(runs);
}

0 comments on commit 4954da8

Please sign in to comment.