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

Commit 4dbafe4

Browse files
committed
fix: split runs into successful and attempted
1 parent 776eae4 commit 4dbafe4

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

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

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -64,45 +64,50 @@ export async function GET(request, { params }) {
6464

6565
// perform checks on these repositories
6666
// use the owners github token (repository->user->account.access_token)
67-
let runs = [];
67+
let runs = { attempted: [], sucessful: [] };
6868
repoStatus.run.map(async (repo) => {
69-
const responses = await getAllRepoData(repo.url, repo.token);
69+
try {
70+
const responses = await getAllRepoData(repo.url, repo.token);
7071

71-
// save github api data
72-
const githubResponseRepo = await prisma.githubResponse.create({
73-
data: {
74-
repository: {
75-
connect: {
76-
id: repo.id,
72+
// save github api data
73+
const githubResponseRepo = await prisma.githubResponse.create({
74+
data: {
75+
repository: {
76+
connect: {
77+
id: repo.id,
78+
},
7779
},
80+
...responses,
7881
},
79-
...responses,
80-
},
81-
});
82+
});
8283

83-
// perform check
84-
const results = checks(githubResponseRepo);
84+
// perform check
85+
const results = checks(githubResponseRepo);
8586

86-
// save results
87-
await prisma.check.create({
88-
data: {
89-
repository: {
90-
connect: { id: repo.id },
91-
},
92-
githubResponse: {
93-
connect: { id: githubResponseRepo.id },
87+
// save results
88+
await prisma.check.create({
89+
data: {
90+
repository: {
91+
connect: { id: repo.id },
92+
},
93+
githubResponse: {
94+
connect: { id: githubResponseRepo.id },
95+
},
96+
red: results.summary.error?.length || 0,
97+
amber: results.summary.warning?.length || 0,
98+
green: results.summary.success?.length || 0,
99+
healthchecks: results.checks.map((check) => check.id),
100+
data: results.checks,
101+
allData: results.allChecks,
102+
ignoreChecks: results.ignoreChecks,
94103
},
95-
red: results.summary.error?.length || 0,
96-
amber: results.summary.warning?.length || 0,
97-
green: results.summary.success?.length || 0,
98-
healthchecks: results.checks.map((check) => check.id),
99-
data: results.checks,
100-
allData: results.allChecks,
101-
ignoreChecks: results.ignoreChecks,
102-
},
103-
});
104+
});
104105

105-
runs.push({ url: repo.url });
106+
runs.sucessful.push({ url: repo.url });
107+
} catch (e) {
108+
console.error(e);
109+
runs.attempted.push({ url: repo.url });
110+
}
106111
});
107112

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

0 commit comments

Comments
 (0)