2022-04-06 18:16:21 +00:00
|
|
|
import type { BuildLog } from '@prisma/client';
|
2022-02-14 08:28:37 +00:00
|
|
|
import { prisma, ErrorHandler } from './common';
|
2022-02-10 14:47:44 +00:00
|
|
|
|
2022-04-06 18:16:21 +00:00
|
|
|
export async function listLogs({
|
|
|
|
|
buildId,
|
|
|
|
|
last = 0
|
|
|
|
|
}: {
|
|
|
|
|
buildId: string;
|
|
|
|
|
last: number;
|
|
|
|
|
}): Promise<BuildLog[] | { status: number; body: { message: string; error: string } }> {
|
2022-02-10 14:47:44 +00:00
|
|
|
try {
|
|
|
|
|
const body = await prisma.buildLog.findMany({
|
|
|
|
|
where: { buildId, time: { gt: last } },
|
|
|
|
|
orderBy: { time: 'asc' }
|
|
|
|
|
});
|
|
|
|
|
return [...body];
|
2022-02-11 20:14:47 +00:00
|
|
|
} catch (error) {
|
2022-02-14 08:28:37 +00:00
|
|
|
return ErrorHandler(error);
|
2022-02-10 14:47:44 +00:00
|
|
|
}
|
|
|
|
|
}
|