The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fixed incomplete GitHub sync (#5310)
Ady Beraud3052b49031f5
diff --git a/packages/twenty-website/src/app/contributors/api/update/route.tsx b/packages/twenty-website/src/app/contributors/api/update/route.tsxdeleted file mode 100644index 7aa85b4bace..00000000000--- a/packages/twenty-website/src/app/contributors/api/update/route.tsx+++ /dev/null@@ -1,57 +0,0 @@-import { graphql } from '@octokit/graphql';-import { desc } from 'drizzle-orm';--import { findOne } from '@/database/database';-import { issueModel, pullRequestModel } from '@/database/model';-import { fetchAssignableUsers } from '@/github-sync/contributors/fetch-assignable-users';-import { saveIssuesToDB } from '@/github-sync/contributors/save-issues-to-db';-import { savePRsToDB } from '@/github-sync/contributors/save-prs-to-db';-import { searchIssuesPRs } from '@/github-sync/contributors/search-issues-prs';-import { IssueNode, PullRequestNode } from '@/github-sync/contributors/types';--export const dynamic = 'force-dynamic';--export async function GET() {- if (!global.process.env.GITHUB_TOKEN) {- return new Response('No GitHub token provided', { status: 500 });- }-- const query = graphql.defaults({- headers: {- Authorization: 'bearer ' + global.process.env.GITHUB_TOKEN,- },- });-- const assignableUsers = await fetchAssignableUsers(query);-- const mostRecentPR = findOne(- pullRequestModel,- desc(pullRequestModel.updatedAt),- );-- const mostRecentIssue = findOne(issueModel, desc(issueModel.updatedAt));-- if (!mostRecentPR || !mostRecentIssue) {- return new Response('Run Init command first', { status: 400 });- }-- const fetchedPRs = (await searchIssuesPRs(- query,- null,- false,- [],- )) as Array<PullRequestNode>;- const fetchedIssues = (await searchIssuesPRs(- query,- null,- true,- [],- )) as Array<IssueNode>;-- savePRsToDB(fetchedPRs, assignableUsers);- saveIssuesToDB(fetchedIssues, assignableUsers);-- return new Response('Data synced', {- status: 200,- });-}diff --git a/packages/twenty-website/src/github-sync/fetch-and-save-github-data.ts b/packages/twenty-website/src/github-sync/fetch-and-save-github-data.tsindex 48616efc5da..434cdb4ad77 100644--- a/packages/twenty-website/src/github-sync/fetch-and-save-github-data.ts+++ b/packages/twenty-website/src/github-sync/fetch-and-save-github-data.ts@@ -39,8 +39,8 @@ export const fetchAndSaveGithubData = async () => {[],)) as Array<IssueNode>;- savePRsToDB(fetchedPRs, assignableUsers);- saveIssuesToDB(fetchedIssues, assignableUsers);+ await savePRsToDB(fetchedPRs, assignableUsers);+ await saveIssuesToDB(fetchedIssues, assignableUsers);console.log('data synched!');};