From 31d9740aac363bb13aa83cd4f12c9df83e9c346d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 15 Sep 2022 09:35:50 +0200 Subject: [PATCH] fix: fallback to db logs --- apps/api/src/routes/api/v1/applications/handlers.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/api/src/routes/api/v1/applications/handlers.ts b/apps/api/src/routes/api/v1/applications/handlers.ts index a8881850b..51798fdaa 100644 --- a/apps/api/src/routes/api/v1/applications/handlers.ts +++ b/apps/api/src/routes/api/v1/applications/handlers.ts @@ -1195,8 +1195,17 @@ export async function getBuildIdLogs(request: FastifyRequest) { try { await fs.stat(file) } catch (error) { + let logs = await prisma.buildLog.findMany({ + where: { buildId, time: { gt: sequence } }, + orderBy: { time: 'asc' } + }); + const data = await prisma.build.findFirst({ where: { id: buildId } }); + const createdAt = day(data.createdAt).utc(); return { - logs: [], + logs: logs.map(log => { + log.time = Number(log.time) + return log + }), took: day().diff(createdAt) / 1000, status: data?.status || 'queued' }