Skip to content

Commit

Permalink
♻️ fetch issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredkiss3 committed Sep 13, 2024
1 parent 6ed42b4 commit e5b50b8
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions scripts/fetchIssues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,14 +508,19 @@ async function insertSingleIssue(issue: GithubIssue) {
if (!user) return null;

const [repository] = await db
.select()
.from(repositories)
.where(
and(
eq(repositories.name, GITHUB_REPOSITORY_NAME),
eq(repositories.creator_id, user.id)
)
);
.insert(repositories)
.values({
name: GITHUB_REPOSITORY_NAME,
creator_id: user.id
})
.onConflictDoUpdate({
target: [repositories.name],
set: {
name: GITHUB_REPOSITORY_NAME,
creator_id: user.id
}
})
.returning();

if (!repository) return null;
/**
Expand Down Expand Up @@ -1146,11 +1151,15 @@ async function main() {
repoName: GITHUB_REPO_SOURCE.name,
cursor: nextCursor
});

nextCursor = pageInfo.endCursor;
hasNextPage = pageInfo.hasNextPage;
totalIssuesFetched += nodes.length;


console.log({
issueFounds: nodes.length,
first: nodes[0]
});
for (const issue of nodes) {
await insertSingleIssue(issue);
}
Expand Down

0 comments on commit e5b50b8

Please sign in to comment.