data reimport

This commit is contained in:
Michael Zhang 2023-09-05 20:45:38 -05:00
parent 841a48a955
commit bbdb03e377
7 changed files with 271 additions and 152 deletions

View file

@ -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;

View file

@ -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")
}

View file

@ -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 (
<main className={styles.main}>
<div className="flex-container column-when-mobile-container">

View file

@ -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;
}

View file

@ -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 (
<div
className="flex-child column-when-mobile" // style="width:40%;height:32em;overflow-y:scroll;position:relative;"
>
<div className="flex-container ratingContainer alternating-bg">
{ratings.map((rating) => {
return (
<div className={classNames(styles.ratingContainer)}>
<div className={styles.setImage}>
<a href={`/mapset/${rating.SetID}`}>
<img
src={`https://b.ppy.sh/thumb/${rating.SetID}l.jpg`}
className={styles.diffThumb}
// onerror="this.onerror=null; this.src='/charts/INF.png';"
/>
</a>
</div>
<div>
<a href={`/profile/${rating.UserID}`}>
<img
src={`https://s.ppy.sh/a/${rating.UserID}`}
className={styles.profilePicture}
title="<?php echo GetUserNameFromId($row['UserID'], $conn); ?>"
/>
</a>
</div>
<div className="flex-child" style={{flex:"0 0 66%"}}>
{/* <a style="display:flex;" href="/profile/<?php echo $row["UserID"]; ?>">
<?php echo GetUserNameFromId($row["UserID"], $conn); ?>
</a> */}
<StarRatingDisplay rating={rating.Score} /> on
<a href={`/mapset/${rating.SetID}`}>" . mb_strimwidth(htmlspecialchars($row["DifficultyName"]), 0, 35, "...") . "</a>";
?>
</div>
</div>
);
})}
{/* <div className="flex-container ratingContainer alternating-bg">
<div
className="flex-child" // style="margin-left:0.5em;"
>
@ -62,7 +100,7 @@ export default async function RatingTable() {
</div>{" "}
on <a href="/mapset/115011">Lan</a>{" "}
</div>
</div>
</div> */}
</div>
);
}

View file

@ -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;
}

View file

@ -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 <i className="star icon-star-half"></i>;
else return <i className="star icon-star"></i>;
});
const backgroundStars = <div className={styles.starBackground}></div>;
return (
<div className={styles.starRatingDisplay}>
{backgroundStars}
<div className={styles.starForeground}>{overlay}</div>
</div>
);
}