Skip to content

Commit

Permalink
feat:current working code for pushing scraped data to database, forei…
Browse files Browse the repository at this point in the history
…gn linking now also works.
  • Loading branch information
DeveloperMindset123 committed Dec 2, 2024
1 parent bcbacc4 commit 5b40bfd
Show file tree
Hide file tree
Showing 12 changed files with 274,704 additions and 638 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ android/
# macOS
.DS_Store

# ignore prisma migrations
**/migrations

# @generated expo-cli sync-8d4afeec25ea8a192358fae2f8e2fc766bdce4ec
# The following patterns were generated by expo-cli

Expand Down
67 changes: 31 additions & 36 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,78 +1,73 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
// @see https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/connect-your-database-typescript-postgresql

// TODO : Cleanup comments afterwards
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
// this is where the databse connection tkaes place
url = env("DATABASE_URL")
}

// * @see https://www.prisma.io/docs/orm/reference/prisma-schema-reference --> for what the different values represent
// ! @see https://www.prisma.io/docs/orm/reference/prisma-schema-reference#id --> explains id
model User {
id String @id @unique @default(uuid())
email String @unique
password String
// ** Horrible security practice btw, but just for the sake of making things work atm, implement solution before pushing to production
plainTextPassword String?
refreshTokens RefreshTokens[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
plainTextPassword String?
refreshTokens RefreshTokens[]
}

model RefreshTokens {
id String @id @unique @default(uuid())
hashedToken String
userId String
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
revoked Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model UserRegistrationDetails {
// TODO : Logic to randomly generate this value
userID Int @id @unique @db.Integer
// String type to support alphanumeric values
userID Int @id @unique
username String @unique
// this will be the identifier to link us to the User database, allowing us to know which registered user's information this is associated with
emailDuplicate String @unique
degreeType String
major String
// ? to indicate that DOB should be optional
DOB String?
CollegeYear Int
pronouns String?
Hobbies String?
Gender String
emailDuplicate String @unique
degreeType String
}

// this model will be used to store the summary format of the data
model RateMyProfessorDataSummary {
id String @id @unique @default(uuid()) //this will randomly generate an unique id
model RateMyProfessorData {
id String @id @unique @default(uuid()) // primary key
department String
professorName String
numRatings Int
avgRatings Float
avgDifficulty Float
// this is a percentage value stored in the form of a string
avgRatings Float
wouldTakeAgain String
department String
numRatings Int
// store the comments in the comment section here
//@see https://www.prisma.io/docs/orm/prisma-schema/data-model/relations/one-to-one-relations
//RateMyProfessorCompleteData RateMyProfessorCompleteData?
// one professor may have multiple comments associated with them
RateMyProfessorComments RateMyProfessorComments[]
}

// this model will be used to store the data about the professor and the comments relevant to the particular professor
model RateMyProfessorCompleteData {
id String @id @unique @default(uuid())
professor_name String
rating Float
department String
comments Json[]
// TODO : foreign relaton model isn't fully working atm
// will simply push the data directly
model RateMyProfessorComments {
professor_name String
department String
comments String[]
foreign_linker_id String //foreign key --> @unique to ensure it follows the one-to-one relation we have setup
// for now, we will connect them manually instead
generated_id String @id @unique @default(uuid())
// fields takes in the list of foregin key
// references takes in the key from the other table we are referencing
// store as JSON data instead
sentimentData Json[]
professorSummary RateMyProfessorData? @relation(fields: [foreign_linker_id], references: [id])
}
2 changes: 1 addition & 1 deletion results.json

Large diffs are not rendered by default.

Loading

0 comments on commit 5b40bfd

Please sign in to comment.