diff --git a/prisma/migrations/20230905213259_initial/migration.sql b/prisma/migrations/20230906014515_initial/migration.sql similarity index 98% rename from prisma/migrations/20230905213259_initial/migration.sql rename to prisma/migrations/20230906014515_initial/migration.sql index f446f17..98cdc7a 100644 --- a/prisma/migrations/20230905213259_initial/migration.sql +++ b/prisma/migrations/20230906014515_initial/migration.sql @@ -56,8 +56,8 @@ CREATE TABLE `beatmaps` ( `BlacklistReason` TEXT NULL, `controversy` DECIMAL(10, 8) NULL, + INDEX `Artist`(`DifficultyName`, `Artist`, `Title`), INDEX `beatmapset_id`(`SetID`), - FULLTEXT INDEX `Artist`(`DifficultyName`, `Artist`, `Title`), PRIMARY KEY (`BeatmapID`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 682cf58..d297721 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,191 +1,217 @@ generator client { - provider = "prisma-client-js" - previewFeatures = ["fullTextIndex", "fullTextSearch"] + provider = "prisma-client-js" } datasource db { - provider = "mysql" - url = "mysql://root:example@localhost:3306/omdb" + provider = "mysql" + url = env("DATABASE_URL") } -model apikeys { - ApiID Int @id @default(autoincrement()) - Name String? @db.Text - ApiKey String? @unique(map: "ApiKey", length: 255) @db.Text - UserID Int? +model ApiKey { + ApiID Int @id @default(autoincrement()) + Name String? @db.Text + ApiKey String? @unique(map: "ApiKey", length: 255) @db.Text + UserID Int? + + @@map("apikeys") } -model beatmap_creators { - BeatmapID Int - CreatorID Int +model BeatmapCreator { + BeatmapID Int + CreatorID Int - @@id([BeatmapID, CreatorID]) - @@index([BeatmapID], map: "idx_BeatmapID") + @@id([BeatmapID, CreatorID]) + @@index([BeatmapID], map: "idx_BeatmapID") + @@map("beatmap_creators") } -model beatmap_edit_requests { - EditID Int @id @default(autoincrement()) - BeatmapID Int? - SetID Int? - UserID Int - EditData Json - Timestamp DateTime @default(now()) @db.Timestamp(0) - Status beatmap_edit_requests_Status? @default(Pending) - EditorID Int? +model BeatmapEditRequest { + EditID Int @id @default(autoincrement()) + BeatmapID Int? + SetID Int? + UserID Int + EditData Json + Timestamp DateTime @default(now()) @db.Timestamp(0) + Status BeatmapEditRequestStatus? @default(Pending) + EditorID Int? + + @@map("beatmap_edit_requests") } -model beatmaps { - BeatmapID Int @id @db.UnsignedMediumInt - SetID Int? @db.UnsignedMediumInt - SetCreatorID Int? - DifficultyName String? @db.VarChar(255) - Mode Int @default(0) @db.UnsignedTinyInt - Status Int @default(0) @db.TinyInt - SR Float @default(0) @db.Float - Rating String? @db.VarChar(45) - ChartRank Int? - ChartYearRank Int? - Timestamp DateTime? @default(now()) @db.Timestamp(0) - RatingCount Int? - WeightedAvg Float? @db.Float - Genre Int? - Lang Int? - Artist String? @db.VarChar(255) - Title String? @db.VarChar(255) - DateRanked DateTime? @db.Timestamp(0) - Blacklisted Boolean @default(false) - BlacklistReason String? @db.Text - controversy Decimal? @db.Decimal(10, 8) +model Beatmap { + BeatmapID Int @id @db.UnsignedMediumInt + SetID Int? @db.UnsignedMediumInt + SetCreatorID Int? + DifficultyName String? @db.VarChar(255) + Mode Int @default(0) @db.UnsignedTinyInt + Status Int @default(0) @db.TinyInt + SR Float @default(0) @db.Float + Rating String? @db.VarChar(45) + ChartRank Int? + ChartYearRank Int? + Timestamp DateTime? @default(now()) @db.Timestamp(0) + RatingCount Int? + WeightedAvg Float? @db.Float + Genre Int? + Lang Int? + Artist String? @db.VarChar(255) + Title String? @db.VarChar(255) + DateRanked DateTime? @db.Timestamp(0) + Blacklisted Boolean @default(false) + BlacklistReason String? @db.Text + controversy Decimal? @db.Decimal(10, 8) - @@index([SetID], map: "beatmapset_id") - @@fulltext([DifficultyName, Artist, Title], map: "Artist") + @@index([DifficultyName, Artist, Title], map: "Artist") + @@index([SetID], map: "beatmapset_id") + @@map("beatmaps") } /// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client. -model beatmapset_nominators { - SetID Int? - NominatorID Int? - Mode Int? +model BeatmapSetNominator { + SetID Int? + NominatorID Int? + Mode Int? - @@unique([SetID, NominatorID, Mode], map: "beatmapset_nominators_pk") - @@index([SetID], map: "beatmapset_nominators_SetID_index") - @@ignore + @@unique([SetID, NominatorID, Mode], map: "beatmapset_nominators_pk") + @@index([SetID], map: "beatmapset_nominators_SetID_index") + @@map("beatmapset_nominators") + @@ignore } -model blacklist { - UserID Int @id +model Blacklist { + UserID Int @id + + @@map("blacklist") } -model comments { - CommentID Int @id @default(autoincrement()) - UserID Int - SetID Int - Comment String? @db.Text - date DateTime? @default(now()) @db.Timestamp(0) +model Comment { + CommentID Int @id @default(autoincrement()) + UserID Int + SetID Int + Comment String? @db.Text + date DateTime? @default(now()) @db.Timestamp(0) + + @@map("comments") } -model descriptor_votes { - VoteID Int @id @default(autoincrement()) - BeatmapID Int - UserID Int - Vote Boolean - DescriptorID Int +model DescriptorVote { + VoteID Int @id @default(autoincrement()) + BeatmapID Int + UserID Int + Vote Boolean + DescriptorID Int - @@unique([BeatmapID, UserID, DescriptorID], map: "descriptor_votes_pk2") - @@index([BeatmapID], map: "descriptor_votes_BeatmapID_index") + @@unique([BeatmapID, UserID, DescriptorID], map: "descriptor_votes_pk2") + @@index([BeatmapID], map: "descriptor_votes_BeatmapID_index") + @@map("descriptor_votes") } -model descriptors { - DescriptorID Int @id @default(autoincrement()) - Name String @unique(map: "descriptors_pk2") @db.VarChar(40) - ShortDescription String? @db.Text - ParentID Int? - Usable Boolean @default(true) +model Descriptor { + DescriptorID Int @id @default(autoincrement()) + Name String @unique(map: "descriptors_pk2") @db.VarChar(40) + ShortDescription String? @db.Text + ParentID Int? + Usable Boolean @default(true) + + @@map("descriptors") } -model logs { - LogID Int @id @default(autoincrement()) - UserID Int - LogData Json? +model Log { + LogID Int @id @default(autoincrement()) + UserID Int + LogData Json? + + @@map("logs") } -model mappernames { - UserID Int @id - Username String? @db.VarChar(255) +model MapperName { + UserID Int @id + Username String? @db.VarChar(255) + + @@map("mappernames") } -model rating_tags { - UserID Int? - BeatmapID Int? - Tag String? @db.VarChar(150) - TagID Int @id @default(autoincrement()) +model RatingTag { + UserID Int? + BeatmapID Int? + Tag String? @db.VarChar(150) + TagID Int @id @default(autoincrement()) - @@unique([BeatmapID, UserID, Tag], map: "rating_tags_pk") + @@unique([BeatmapID, UserID, Tag], map: "rating_tags_pk") + @@map("rating_tags") } -model ratings { - RatingID Int @id @default(autoincrement()) - BeatmapID Int - UserID Int - Score Decimal? @db.Decimal(2, 1) - date DateTime @db.DateTime(0) +model Rating { + RatingID Int @id @default(autoincrement()) + BeatmapID Int + UserID Int + Score Decimal? @db.Decimal(2, 1) + date DateTime @db.DateTime(0) - @@index([BeatmapID], map: "idx_beatmapID") + @@index([BeatmapID], map: "idx_beatmapID") + @@map("ratings") } /// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client. -model setretrieveinfo { - LastRetrieval DateTime? @db.DateTime(0) - LastDate DateTime? @db.Date +model SetRetrieveInfo { + LastRetrieval DateTime? @db.DateTime(0) + LastDate DateTime? @db.Date - @@ignore + @@map("setretrieveinfo") + @@ignore } /// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client. -model user_correlations { - user1_id Int? - user2_id Int? - correlation Float? @db.Float +model UserCorrelation { + user1_id Int? + user2_id Int? + correlation Float? @db.Float - @@unique([user1_id, user2_id], map: "user_correlations_pk") - @@ignore + @@unique([user1_id, user2_id], map: "user_correlations_pk") + @@map("user_correlations") + @@ignore } /// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client. -model user_relations { - UserIDFrom Int? - UserIDTo Int? - type Int? +model UserRelation { + UserIDFrom Int? + UserIDTo Int? + type Int? - @@unique([UserIDTo, UserIDFrom], map: "user_relations_pk") - @@ignore + @@unique([UserIDTo, UserIDFrom], map: "user_relations_pk") + @@map("user_relations") + @@ignore } -model users { - UserID Int @id - Username String? @db.VarChar(255) - AccessToken String? @db.VarChar(2000) - RefreshToken String? @db.VarChar(2000) - banned Boolean? @default(false) - Weight Decimal? @db.Decimal(6, 4) - DoTrueRandom Boolean @default(false) - Custom00Rating String @default("") @db.VarChar(60) - Custom05Rating String @default("") @db.VarChar(60) - Custom10Rating String @default("") @db.VarChar(60) - Custom15Rating String @default("") @db.VarChar(60) - Custom20Rating String @default("") @db.VarChar(60) - Custom25Rating String @default("") @db.VarChar(60) - Custom30Rating String @default("") @db.VarChar(60) - Custom35Rating String @default("") @db.VarChar(60) - Custom40Rating String @default("") @db.VarChar(60) - Custom45Rating String @default("") @db.VarChar(60) - Custom50Rating String @default("") @db.VarChar(60) - LastAccessedSite DateTime @default(now()) @db.Timestamp(0) - HideRatings Boolean? @default(false) +model User { + UserID Int @id + Username String? @db.VarChar(255) + AccessToken String? @db.VarChar(2000) + RefreshToken String? @db.VarChar(2000) + banned Boolean? @default(false) + Weight Decimal? @db.Decimal(6, 4) + DoTrueRandom Boolean @default(false) + Custom00Rating String @default("") @db.VarChar(60) + Custom05Rating String @default("") @db.VarChar(60) + Custom10Rating String @default("") @db.VarChar(60) + Custom15Rating String @default("") @db.VarChar(60) + Custom20Rating String @default("") @db.VarChar(60) + Custom25Rating String @default("") @db.VarChar(60) + Custom30Rating String @default("") @db.VarChar(60) + Custom35Rating String @default("") @db.VarChar(60) + Custom40Rating String @default("") @db.VarChar(60) + Custom45Rating String @default("") @db.VarChar(60) + Custom50Rating String @default("") @db.VarChar(60) + LastAccessedSite DateTime @default(now()) @db.Timestamp(0) + HideRatings Boolean? @default(false) + + @@map("users") } -enum beatmap_edit_requests_Status { - Pending - Denied - Approved +enum BeatmapEditRequestStatus { + Pending + Denied + Approved + + @@map("beatmap_edit_requests_Status") } diff --git a/src/app/page.tsx b/src/app/page.tsx index ad4bad4..536ed16 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,18 +3,7 @@ import styles from "./page.module.css"; import { PrismaClient } from "@prisma/client"; import RatingTable from "@/components/RatingTable"; -export async function getData() { - const prisma = new PrismaClient(); - - const comments = await prisma.comments.findMany({ take: 20 }); - - return { comments }; -} - export default async function Home() { - const data = await getData(); - console.log("data", data); - return (
diff --git a/src/components/RatingTable.module.scss b/src/components/RatingTable.module.scss index e69de29..84ba259 100644 --- a/src/components/RatingTable.module.scss +++ b/src/components/RatingTable.module.scss @@ -0,0 +1,20 @@ +.ratingContainer { + background-color: var(--accent-1); + align-items: center; +} + +.setImage { + margin-left: 0.5em; +} + +.diffThumb { + height: 32px; + width: 32px; + border: 1px solid #ddd; + object-fit: cover; +} + +.profilePicture { + width: 24px; + height: 24px; +} diff --git a/src/components/RatingTable.tsx b/src/components/RatingTable.tsx index e2e82bf..4202e17 100644 --- a/src/components/RatingTable.tsx +++ b/src/components/RatingTable.tsx @@ -1,20 +1,58 @@ +import classNames from "classnames"; import styles from "./RatingTable.module.scss"; import { PrismaClient } from "@prisma/client"; +import StarRatingDisplay from "./StarRatingDisplay"; export async function getData() { const prisma = new PrismaClient(); + const ratings = await prisma.ratings.findMany({ take: 20 }); const comments = await prisma.comments.findMany({ take: 20 }); - return { comments }; + return { ratings, comments }; } export default async function RatingTable() { + const { ratings} = await getData(); + return (
-
+ {ratings.map((rating) => { + return ( +
+
+ + + +
+
+ + + +
+ + +
+ ); + })} + {/*
@@ -62,7 +100,7 @@ export default async function RatingTable() {
{" "} on Lan{" "}
-
+
*/}
); } diff --git a/src/components/StarRatingDisplay.module.scss b/src/components/StarRatingDisplay.module.scss new file mode 100644 index 0000000..ece95d1 --- /dev/null +++ b/src/components/StarRatingDisplay.module.scss @@ -0,0 +1,20 @@ +.starRatingDisplay { + display: inline-block; + white-space: nowrap; + width: 5em; + padding-right: 0.25em; +} + +.starBackground { + color: #203838; + z-index: 0; + display: inline-block; + position: absolute; +} + +.starForeground { + color: white; + z-index: 2; + display: inline-block; + position: relative; +} diff --git a/src/components/StarRatingDisplay.tsx b/src/components/StarRatingDisplay.tsx new file mode 100644 index 0000000..77b9acb --- /dev/null +++ b/src/components/StarRatingDisplay.tsx @@ -0,0 +1,26 @@ +import { Decimal } from "@prisma/client/runtime/library"; +import styles from "./StarRatingDisplay.module.scss"; + +export interface Props { + rating: Decimal; +} + +export default function StarRatingDisplay({ rating }: Props) { + const ratingNumber = rating.toNumber(); + const overlay = [0, 1, 2, 3, 4] + .filter((x) => x < ratingNumber) + .map((x) => { + if (ratingNumber - 0.5 === x) + return ; + else return ; + }); + + const backgroundStars =
; + + return ( +
+ {backgroundStars} +
{overlay}
+
+ ); +}