check database for existing changelogs before importing releases
This commit is contained in:
@@ -182,13 +182,25 @@ async function syncRepos(ctx) {
|
|||||||
const releaseKey = `${repo.fullName}:${release.id}`;
|
const releaseKey = `${repo.fullName}:${release.id}`;
|
||||||
if (imported.has(releaseKey)) continue;
|
if (imported.has(releaseKey)) continue;
|
||||||
|
|
||||||
|
const title = `${titleCase(repo.name)} ${release.name}`;
|
||||||
|
|
||||||
|
// check if this changelog already exists in the database
|
||||||
|
const exists = await ctx.prisma.changelogEntry.findFirst({
|
||||||
|
where: { title, boardId: board.id },
|
||||||
|
select: { id: true },
|
||||||
|
});
|
||||||
|
if (exists) {
|
||||||
|
imported.add(releaseKey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const body = release.body
|
const body = release.body
|
||||||
? `${release.body}\n\n[View release](${release.htmlUrl})`
|
? `${release.body}\n\n[View release](${release.htmlUrl})`
|
||||||
: `[View release](${release.htmlUrl})`;
|
: `[View release](${release.htmlUrl})`;
|
||||||
|
|
||||||
await ctx.prisma.changelogEntry.create({
|
await ctx.prisma.changelogEntry.create({
|
||||||
data: {
|
data: {
|
||||||
title: `${titleCase(repo.name)} ${release.name}`,
|
title,
|
||||||
body,
|
body,
|
||||||
boardId: board.id,
|
boardId: board.id,
|
||||||
publishedAt: new Date(release.publishedAt),
|
publishedAt: new Date(release.publishedAt),
|
||||||
|
|||||||
Reference in New Issue
Block a user