Skip to content

Commit

Permalink
Merge pull request #25 from checkly/release_model
Browse files Browse the repository at this point in the history
adding a test to fill the db
  • Loading branch information
schobele authored Dec 13, 2024
2 parents 4f9e118 + 0da0e8f commit 9e132e9
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/routes/githubwebhook.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { PrismaClient } from "@prisma/client";
import GitHubAPI from "../github/github";
import { getOpenaiSDKClient } from "../ai/openai";
import { GithubAgent } from "../github/agent";

const prisma = new PrismaClient();
const CHECKLY_GITHUB_TOKEN = process.env.CHECKLY_GITHUB_TOKEN!;

const github = new GitHubAPI(CHECKLY_GITHUB_TOKEN);

let setupAgent = () => {
let openai = getOpenaiSDKClient();

return new GithubAgent(openai("gpt-4o"), github);
};

const githubAgent = setupAgent();

describe("Load github releases into db", () => {
it.skip("should add releases to the db", async () => {
const org = "checkly";
const repo = "checkly-backend";
const timeframe = "1 days";

let summary = await githubAgent.summarizeReleases(
`what has changed in the ${repo} within the last ${timeframe}`,
org
);

for (const release of summary.releases) {
const authors = release.authors
.filter((author) => author !== null)
.map((author) => author.login);

await prisma.release.create({
data: {
name: release.id,
releaseUrl: release.link,
publishedAt: release.release_date,
org: org,
repo: summary.repo.name,
repoUrl: summary.repo.link,
tag: release.id,
diffUrl: release.diffLink,
authors,
summary: release.summary,
}
});
}
}, 600000000);
});

0 comments on commit 9e132e9

Please sign in to comment.