Skip to content

Commit

Permalink
Data Generator (#23)
Browse files Browse the repository at this point in the history
* Dummy Data Init

Dummy Data init

* prepare for testing

* openai

* test runs

* dummy data

* dummy data pt2

* Fix env var and other lint errors

* Add fonts and colors from Figma (#18)

* Add Space Mono font

* Add colors from Figma

* Create Delete, Stop, Start endpoints (#19)

* changes for frontend some css errors just didnt know fonts and colors… (#17)

* changes for frontend some css errors just didnt know fonts and colors and etc very quick fixes

* issue with text field

* Sign in page complete

* Cleanup

* New icons and stuff

* Create Delete, Stop, Start endpoints (#19)

* Snazzy stuff

* Actually query projects

* Fix some TRPC routes

* Fix links and other info

* Semi decent search

* added comments saying if a github add is valid and pasue and starts for databases

* Fix some errors

* Create Delete, Stop, Start endpoints (#19)

* Fix database router

---------

Co-authored-by: Nate Sawant <[email protected]>
Co-authored-by: Nate Sawant <[email protected]>

* Protect procedure

* grind session

* 5 maximum tries

* full schema

* lint

* lint

* fix database

* fix database

* CLI Parity (#25)

* temp changes

* Write config to file

* View projects and options

* Fix undefined error

* Add options to modify project

* Way to add current repo

* Fix schema pushing (#26)

* Fix package

* Correct pushing of schema

* Fix bug with invalid existing interceptor (#27)

* Fix env var and other lint errors

* Add fonts and colors from Figma (#18)

* Add Space Mono font

* Add colors from Figma

* changes for frontend some css errors just didnt know fonts and colors… (#17)

* changes for frontend some css errors just didnt know fonts and colors and etc very quick fixes

* issue with text field

* Sign in page complete

* Cleanup

* New icons and stuff

* Create Delete, Stop, Start endpoints (#19)

* Snazzy stuff

* Actually query projects

* Fix some TRPC routes

* Fix links and other info

* Semi decent search

* added comments saying if a github add is valid and pasue and starts for databases

* Fix some errors

* Create Delete, Stop, Start endpoints (#19)

* Fix database router

---------

Co-authored-by: Nate Sawant <[email protected]>
Co-authored-by: Nate Sawant <[email protected]>

* grind session

* fix database

* Fix errors

* Fix conflict

* Fix OpenAI env var

* attempt 2

---------

Co-authored-by: patela22 <[email protected]>
Co-authored-by: Nate Sawant <[email protected]>
Co-authored-by: Nate Sawant <[email protected]>
Co-authored-by: kaamil2 <[email protected]>
  • Loading branch information
5 people authored Jun 20, 2024
1 parent c3a900d commit a807621
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 90 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"next-auth": "^4.24.6",
"nextjs-cors": "^2.2.0",
"octokit": "^4.0.2",
"openai": "^4.47.3",
"parse-git-config": "^3.0.0",
"parse-github-url": "^1.0.2",
"react": "18.2.0",
Expand Down
163 changes: 89 additions & 74 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -2,111 +2,126 @@
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
}

datasource db {
provider = "postgresql"
// NOTE: When using mysql or sqlserver, uncomment the @db.Text annotations in model Account below
// Further reading:
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
url = env("DATABASE_URL")
provider = "postgresql"
// NOTE: When using mysql or sqlserver, uncomment the @db.Text annotations in model Account below
// Further reading:
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
url = env("DATABASE_URL")
}

model Post {
id String @id @default(cuid()) // do not generate id
name String
title String
description String //make this 40 characters long and about a dog
dateUploaded DateTime? // make this
likes Like[]
}

model Like {
id String @id @default(cuid()) // do not generate id
postId String
post Post @relation(fields: [postId], references: [id])
}

// Necessary for Next auth
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? // @db.Text
refresh_token_expires_in Int?
access_token String? // @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? // @db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? // @db.Text
refresh_token_expires_in Int?
access_token String? // @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? // @db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}

model VerifiedEmails {
email String @id
email String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([email])
@@unique([email])
}

model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
branches Branch[]
projects Project[]
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
branches Branch[]
projects Project[]
}

model VerificationToken {
identifier String
token String @unique
expires DateTime
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
@@unique([identifier, token])
}

model Project {
owner String
ownerName String
repository String
repositoryName String
branches Branch[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdBy User @relation(fields: [createdById], references: [id], onDelete: Cascade, onUpdate: Cascade)
createdById String
rdsInstance RDSInstance? @relation(fields: [rdsInstanceId], references: [id])
rdsInstanceId String?
@@unique([repository])
@@index([ownerName, repositoryName, owner, repository])
owner String
ownerName String
repository String
repositoryName String
branches Branch[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdBy User @relation(fields: [createdById], references: [id], onDelete: Cascade, onUpdate: Cascade)
createdById String
rdsInstance RDSInstance? @relation(fields: [rdsInstanceId], references: [id])
rdsInstanceId String?
@@unique([repository])
@@index([ownerName, repositoryName, owner, repository])
}

model RDSInstance {
id String @id @default(cuid())
baseConnection String?
project Project[]
id String @id @default(cuid())
baseConnection String?
project Project[]
}

model Branch {
id String @id @default(cuid())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
id String @id @default(cuid())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdBy User @relation(fields: [createdById], references: [id], onDelete: Cascade, onUpdate: Cascade)
createdById String
project Project @relation(fields: [projectRepository], references: [repository], onDelete: Cascade, onUpdate: Cascade)
projectRepository String
createdBy User @relation(fields: [createdById], references: [id], onDelete: Cascade, onUpdate: Cascade)
createdById String
project Project @relation(fields: [projectRepository], references: [repository], onDelete: Cascade, onUpdate: Cascade)
projectRepository String
@@unique([projectRepository, name])
@@unique([projectRepository, name])
}
19 changes: 3 additions & 16 deletions src/app/_components/DashboardContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { api } from "~/trpc/react";
import { useState } from "react";
import ProjectList from "./ProjectList";
import SearchInput from "./SearchInput";
import Link from "next/link";

export default function DashboardItems() {
const [searchTerm, setSearchTerm] = useState("");
Expand All @@ -22,17 +21,13 @@ export default function DashboardItems() {
searchTerms: searchTerm,
});

const nukeMutation = api.database.nuke.useMutation();

const mappedProjects = projectsData?.map((project) => {
console.log(project.rdsInstanceId);

return {
projectName: project.repository,
route: project.repository,
branchesCount: project.branches.length,
databasesCount: project.branches.length,
instanceStatus: project.status,
instanceStatus: "Unknown",
branches: project.branches.map((branch) => {
return {
creator: branch.createdBy.name ?? "Unknown",
Expand All @@ -49,22 +44,14 @@ export default function DashboardItems() {

return (
<div className="flex flex-col gap-8">
<div className=" flex flex-row justify-between">
<SearchInput searchTerm={searchTerm} setSearchTerm={setSearchTerm} />
<button onClick={() => nukeMutation.mutate()}>
Nuke All Instances
</button>
</div>
<SearchInput searchTerm={searchTerm} setSearchTerm={setSearchTerm} />
{isLoading && <div>Loading...</div>}
{error && <div>Error: {error.message}</div>}
{!isLoading &&
!error &&
(!mappedProjects || mappedProjects.length === 0) && (
<div className="text-center py-24 text-3xl">
No available projects.{" "}
<Link className=" underline" href={"new-project"}>
Create a new project?
</Link>
No available projects
</div>
)}
{mappedProjects && (
Expand Down
24 changes: 24 additions & 0 deletions src/app/dummy/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use client";

import { useState } from "react";
import { api } from "~/trpc/react";

export default function Dummy() {
const [results, setResults] = useState("");
const testDummy = api.dummy.testDummy.useMutation();

const handleCreateDummyData = () => {
testDummy
.mutateAsync({ name: "test" })
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
.then((data) => setResults(`success: ${data.message}`))
.catch((error) => console.error(error));
};

return (
<main className="flex min-h-screen flex-col items-center justify-center bg-gradient-to-b from-[#2e026d] to-[#15162c] text-white">
<button onClick={handleCreateDummyData}>Create Data</button>
<div>{results}</div>
</main>
);
}
4 changes: 4 additions & 0 deletions src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const env = createEnv({
AWS_ACCESS_KEY_ID: z.string(),
AWS_SECRET_ACCESS_KEY: z.string(),
AWS_SESSION_TOKEN: z.string().optional(),
OPENAI_API_KEY: z.string(),
OPENAI_ORG_ID: z.string(),
},

/**
Expand Down Expand Up @@ -56,6 +58,8 @@ export const env = createEnv({
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY,
AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN,
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
OPENAI_ORG_ID: process.env.OPENAI_ORG_ID,
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
Expand Down
2 changes: 2 additions & 0 deletions src/server/api/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createCallerFactory, createTRPCRouter } from "~/server/api/trpc";
import { greeting } from "./routers/greeting";
import { project } from "./routers/project";
import { githubWebhookRouter } from "./routers/prisma";
import { dummy } from "./routers/dummy";

/**
* This is the primary router for your server.
Expand All @@ -14,6 +15,7 @@ export const appRouter = createTRPCRouter({
health: greeting,
database: project,
webhook: githubWebhookRouter,
dummy: dummy,
});

// export type definition of API
Expand Down
14 changes: 14 additions & 0 deletions src/server/api/routers/dummy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { z } from "zod";

import dummyCreate from "~/server/dummyData";
import { createTRPCRouter, publicProcedure } from "~/server/api/trpc";

export const dummy = createTRPCRouter({
testDummy: publicProcedure
.input(z.object({ name: z.string() }))
.mutation(async () => {
const results = await dummyCreate();

return results;
}),
});
Loading

0 comments on commit a807621

Please sign in to comment.