Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Create createTeamAndMatchUser.ts #337

Merged
merged 5 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/api/actions/github/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import { NextResponse } from "next/server";
import getAllServices from "../../../../utils/actions/getAllServices";
import randomText from "../../../../utils/actions/markdownHelpers/randomText";
import createTeamAndMatchUser from "../../../../utils/db/teams/createTeamAndMatchUser";
const app = new App({
appId: process.env.GITHUB_APP_ID!,
privateKey: process.env.GITHUB_PRIVATE_KEY!,
Expand Down Expand Up @@ -53,7 +54,7 @@ export async function POST(request: Request) {
if (missingParams.length > 0) {
return missingParamsResponse({ url: request.url, missingParams });
}
const { installation, repository, pull_request } = req;
const { installation, repository, pull_request, organization } = req;
const installationId = installation.id;
const { title, body } = req.pull_request;
const owner = repository.owner.login;
Expand Down Expand Up @@ -328,6 +329,12 @@ export async function POST(request: Request) {
}
}

const team = await createTeamAndMatchUser({
name: organization.login,
id: organization.id,
watermelon_user,
});

const count = await addActionCount({ owner });

textToWrite += `### WatermelonAI Summary \n`;
Expand Down
8 changes: 8 additions & 0 deletions utils/db/teams/createTeamAndMatchUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import executeRequest from "../azuredb";

export default async ({ name, id, watermelon_user }) => {
let query = await executeRequest(
`EXEC dbo.create_new_team_and_match_user @name = '${name}', @id = '${id}', @user_id = '${watermelon_user}'`
);
return query;
};