From 998e6a43121fd4b1e86b3256c6200aaa04e5bb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Mon, 16 Sep 2024 09:23:33 +0200 Subject: [PATCH] Fix contributor script --- .../github/contributors/save-issues-to-db.tsx | 25 +++++++++++++++--- .../github/contributors/save-prs-to-db.tsx | 26 ++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/packages/twenty-website/src/github/contributors/save-issues-to-db.tsx b/packages/twenty-website/src/github/contributors/save-issues-to-db.tsx index f7cb48e68214c..775084cb45afc 100644 --- a/packages/twenty-website/src/github/contributors/save-issues-to-db.tsx +++ b/packages/twenty-website/src/github/contributors/save-issues-to-db.tsx @@ -25,7 +25,13 @@ export async function saveIssuesToDB( isEmployee: assignableUsers.has(issue.author.login) ? '1' : '0', }, ], - { onConflictKey: 'id' }, + { onConflictKey: 'id', + onConflictUpdateObject: { + avatarUrl: issue.author.avatarUrl, + url: issue.author.url, + isEmployee: assignableUsers.has(issue.author.login) ? '1' : '0', + } + }, ); await insertMany( @@ -44,7 +50,14 @@ export async function saveIssuesToDB( ], { onConflictKey: 'id', - onConflictUpdateObject: { updatedAt: issue.updatedAt }, + onConflictUpdateObject: { + title: issue.title, + body: issue.body, + url: issue.url, + updatedAt: issue.updatedAt, + closedAt: issue.closedAt, + authorId: issue.author.login, + }, }, ); @@ -59,7 +72,13 @@ export async function saveIssuesToDB( description: label.description, }, ], - { onConflictKey: 'id' }, + { onConflictKey: 'id', + onConflictUpdateObject: { + name: label.name, + color: label.color, + description: label.description, + } + }, ); await insertMany(issueLabelModel, [ { diff --git a/packages/twenty-website/src/github/contributors/save-prs-to-db.tsx b/packages/twenty-website/src/github/contributors/save-prs-to-db.tsx index 892b5565fcfca..b5feaf2629435 100644 --- a/packages/twenty-website/src/github/contributors/save-prs-to-db.tsx +++ b/packages/twenty-website/src/github/contributors/save-prs-to-db.tsx @@ -26,7 +26,13 @@ export async function savePRsToDB( isEmployee: assignableUsers.has(pr.author.login) ? '1' : '0', }, ], - { onConflictKey: 'id' }, + { onConflictKey: 'id', + onConflictUpdateObject: { + avatarUrl: pr.author.avatarUrl, + url: pr.author.url, + isEmployee: assignableUsers.has(pr.author.login) ? '1' : '0', + } + }, ); await insertMany( @@ -46,7 +52,15 @@ export async function savePRsToDB( ], { onConflictKey: 'id', - onConflictUpdateObject: { title: pr.title, updatedAt: pr.updatedAt }, + onConflictUpdateObject: { + title: pr.title, + body: pr.body, + url: pr.url, + updatedAt: pr.updatedAt, + closedAt: pr.closedAt, + mergedAt: pr.mergedAt, + authorId: pr.author.login, + }, }, ); @@ -61,7 +75,13 @@ export async function savePRsToDB( description: label.description, }, ], - { onConflictKey: 'id' }, + { onConflictKey: 'id', + onConflictUpdateObject: { + name: label.name, + color: label.color, + description: label.description, + } + }, ); await insertMany(pullRequestLabelModel, [ {