Skip to content

Commit

Permalink
Merge pull request #19 from J-hoplin1/feat/problem-issue
Browse files Browse the repository at this point in the history
Feat/problem issue
  • Loading branch information
J-Hoplin authored Jan 14, 2024
2 parents e9e5740 + f4533c2 commit dee3425
Show file tree
Hide file tree
Showing 45 changed files with 1,719 additions and 142 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pre-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}

e2e-testing:
needs: unit-testing
runs-on: ubuntu-latest
steps:
- name: Repository Checkout
Expand Down
9 changes: 8 additions & 1 deletion .platform/hooks/predeploy/01_database_init.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
#!/usr/bin/env bash
node node_modules/prisma/build/index.js db push

# Add database migration script
node node_modules/prisma/build/index.js migrate resolve --applied 20240109151719_submission_ispulic
node node_modules/prisma/build/index.js migrate resolve --applied 20240113073649_problem_issue_comment
node node_modules/prisma/build/index.js migrate resolve --applied 20240113161205_problem_issue_comment_user
node node_modules/prisma/build/index.js migrate resolve --applied 20240114010304_chagne_issue_comment_name
node node_modules/prisma/build/index.js migrate resolve --applied 20240114021108_issue_comment_problem_relation
node node_modules/prisma/build/index.js migrate resolve --applied 20240114021239_modify_problem_issue_problem
1 change: 1 addition & 0 deletions domain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './user.domain';
export * from './problem-example.domain';
export * from './submission.domain';
export * from './problem-issue.domain';
export * from './problem-issue-comment.domain';
19 changes: 19 additions & 0 deletions domain/problem-issue-comment.domain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ApiProperty } from '@nestjs/swagger';
import { ProblemIssueComment } from '@prisma/client';

export class ProblemIssueCommentDomain implements ProblemIssueComment {
@ApiProperty()
id: number;

@ApiProperty()
content: string;

@ApiProperty()
issueId: number;

@ApiProperty()
problemId: number;

@ApiProperty()
userId: string;
}
2 changes: 1 addition & 1 deletion domain/problem-issue.domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ProblemIssueDomain implements ProblemIssue {
content: string;

@ApiProperty()
targetId: number;
problemId: number;

@ApiProperty()
issuerId: string;
Expand Down
3 changes: 3 additions & 0 deletions domain/submission.domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export class SubmissionDomain implements Submission {
@ApiProperty()
time: number;

@ApiProperty()
isPublic: boolean;

@ApiProperty()
languageId: number;

Expand Down
17 changes: 0 additions & 17 deletions prisma/migrations/20231203061100_user_type_migration/migration.sql

This file was deleted.

35 changes: 0 additions & 35 deletions prisma/migrations/20231209021219_judge/migration.sql

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
/*
Warnings:
- You are about to drop the `problemexample` table. If the table is not empty, all the data it contains will be lost.
- Added the required column `tags` to the `problem` table without a default value. This is not possible if the table is not empty.
-- CreateTable
CREATE TABLE `user` (
`id` VARCHAR(191) NOT NULL,
`nickname` VARCHAR(191) NOT NULL,
`password` VARCHAR(191) NOT NULL,
`email` VARCHAR(191) NOT NULL,
`message` VARCHAR(191) NULL,
`github` VARCHAR(191) NULL,
`blog` VARCHAR(191) NULL,
`type` ENUM('Admin', 'Contributer', 'User') NULL DEFAULT 'User',
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updatedAt` DATETIME(3) NOT NULL,

*/
-- DropForeignKey
ALTER TABLE `problemexample` DROP FOREIGN KEY `problemexample_problemId_fkey`;
UNIQUE INDEX `user_nickname_key`(`nickname`),
UNIQUE INDEX `user_email_key`(`email`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AlterTable
ALTER TABLE `problem` ADD COLUMN `deletedAt` DATETIME(3) NULL,
ADD COLUMN `isArchived` BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN `tags` JSON NOT NULL,
MODIFY `title` VARCHAR(191) NOT NULL DEFAULT 'New Problem',
MODIFY `problem` VARCHAR(191) NOT NULL DEFAULT 'Problem Here',
MODIFY `input` VARCHAR(191) NOT NULL DEFAULT 'Input Here',
MODIFY `output` VARCHAR(191) NOT NULL DEFAULT 'Output Here',
MODIFY `timeLimit` INTEGER NOT NULL DEFAULT 5,
MODIFY `memoryLimit` INTEGER NOT NULL DEFAULT 128;
-- CreateTable
CREATE TABLE `problem` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`title` VARCHAR(191) NOT NULL DEFAULT 'New Problem',
`problem` VARCHAR(191) NOT NULL DEFAULT 'Problem Here',
`input` VARCHAR(191) NOT NULL DEFAULT 'Input Here',
`output` VARCHAR(191) NOT NULL DEFAULT 'Output Here',
`timeLimit` INTEGER NOT NULL DEFAULT 5,
`memoryLimit` INTEGER NOT NULL DEFAULT 128,
`contributerId` VARCHAR(191) NOT NULL,
`tags` JSON NOT NULL,
`isArchived` BOOLEAN NOT NULL DEFAULT false,
`deletedAt` DATETIME(3) NULL,
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updatedAt` DATETIME(3) NOT NULL,

-- DropTable
DROP TABLE `problemexample`;
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `problem_example` (
Expand All @@ -40,12 +53,15 @@ CREATE TABLE `submission` (
`codeLength` INTEGER NOT NULL DEFAULT 0,
`memory` DOUBLE NOT NULL DEFAULT 0,
`time` DOUBLE NOT NULL DEFAULT 0,
`isPublic` BOOLEAN NOT NULL DEFAULT false,
`languageId` INTEGER NOT NULL,
`language` VARCHAR(191) NOT NULL,
`isCorrect` BOOLEAN NOT NULL,
`response` ENUM('CORRECT', 'WRONG_ANSWER', 'TIME_LIMIT_EXCEED', 'COMPILE_ERROR', 'RUNTIME_ERROR_SIGSEGV', 'RUNTIME_ERROR_SIGXFSZ', 'RUNTIME_ERROR_SIGFPE', 'RUNTIME_ERROR_SIGABRT', 'RUNTIME_ERROR_NZEC', 'RUNTIME_ERROR', 'INTERNAL_ERROR', 'EXEC_FORMAT_ERROR', 'MEMORY_LIMIT_EXCEED') NOT NULL,
`userId` VARCHAR(191) NOT NULL,
`problemId` INTEGER NOT NULL,
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updatedAt` DATETIME(3) NOT NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Expand All @@ -61,6 +77,9 @@ CREATE TABLE `problem_issue` (
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `problem` ADD CONSTRAINT `problem_contributerId_fkey` FOREIGN KEY (`contributerId`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `problem_example` ADD CONSTRAINT `problem_example_problemId_fkey` FOREIGN KEY (`problemId`) REFERENCES `problem`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- CreateTable
CREATE TABLE `problem_issue_comment` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`content` TEXT NOT NULL,
`problemId` INTEGER NOT NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `problem_issue_comment` ADD CONSTRAINT `problem_issue_comment_problemId_fkey` FOREIGN KEY (`problemId`) REFERENCES `problem_issue`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- Added the required column `userId` to the `problem_issue_comment` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `problem_issue_comment` ADD COLUMN `userId` VARCHAR(191) NOT NULL;

-- AddForeignKey
ALTER TABLE `problem_issue_comment` ADD CONSTRAINT `problem_issue_comment_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Warnings:
- You are about to drop the column `problemId` on the `problem_issue_comment` table. All the data in the column will be lost.
- Added the required column `issueId` to the `problem_issue_comment` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE `problem_issue_comment` DROP FOREIGN KEY `problem_issue_comment_problemId_fkey`;

-- AlterTable
ALTER TABLE `problem_issue` MODIFY `title` VARCHAR(100) NOT NULL DEFAULT 'Title Here';

-- AlterTable
ALTER TABLE `problem_issue_comment` DROP COLUMN `problemId`,
ADD COLUMN `issueId` INTEGER NOT NULL;

-- AddForeignKey
ALTER TABLE `problem_issue_comment` ADD CONSTRAINT `problem_issue_comment_issueId_fkey` FOREIGN KEY (`issueId`) REFERENCES `problem_issue`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- Added the required column `problemId` to the `problem_issue_comment` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `problem_issue_comment` ADD COLUMN `problemId` INTEGER NOT NULL;

-- AddForeignKey
ALTER TABLE `problem_issue_comment` ADD CONSTRAINT `problem_issue_comment_problemId_fkey` FOREIGN KEY (`problemId`) REFERENCES `problem`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Warnings:
- You are about to drop the column `targetId` on the `problem_issue` table. All the data in the column will be lost.
- Added the required column `problemId` to the `problem_issue` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE `problem_issue` DROP FOREIGN KEY `problem_issue_targetId_fkey`;

-- AlterTable
ALTER TABLE `problem_issue` DROP COLUMN `targetId`,
ADD COLUMN `problemId` INTEGER NOT NULL;

-- AddForeignKey
ALTER TABLE `problem_issue` ADD CONSTRAINT `problem_issue_problemId_fkey` FOREIGN KEY (`problemId`) REFERENCES `problem`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
59 changes: 39 additions & 20 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ datasource db {
}

model User {
id String @id @default(uuid())
nickname String @unique
id String @id @default(uuid())
nickname String @unique
password String
email String @unique
email String @unique
message String?
github String?
blog String?
type UserType? @default(User)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
type UserType? @default(User)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
problems Problem[]
Submission Submission[]
Issues ProblemIssue[]
IssueComments ProblemIssueComment[]
@@map("user")
}
Expand Down Expand Up @@ -53,9 +54,10 @@ model Problem {
tags Json
isArchived Boolean @default(false)
deletedAt DateTime?
deletedAt DateTime?
issues ProblemIssue[]
issues ProblemIssue[]
comments ProblemIssueComment[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand All @@ -82,10 +84,10 @@ enum ResponseType {
TIME_LIMIT_EXCEED // 5
COMPILE_ERROR // 6
RUNTIME_ERROR_SIGSEGV // 7
RUNTIME_ERROR_SIGXFSZ //8
RUNTIME_ERROR_SIGXFSZ // 8
RUNTIME_ERROR_SIGFPE // 9
RUNTIME_ERROR_SIGABRT // 10
RUNTIME_ERROR_NZEC //11
RUNTIME_ERROR_NZEC // 11
RUNTIME_ERROR // 12
INTERNAL_ERROR // 13
EXEC_FORMAT_ERROR // 14
Expand All @@ -98,6 +100,7 @@ model Submission {
codeLength Int @default(0)
memory Float @default(0) // KB
time Float @default(0) // second
isPublic Boolean @default(false)
languageId Int // Language ID
language String // Language Name
isCorrect Boolean
Expand All @@ -117,17 +120,33 @@ model Submission {
}

model ProblemIssue {
id Int @id @default(autoincrement())
title String @db.VarChar(100)
content String @db.Text
id Int @id @default(autoincrement())
title String @db.VarChar(100) @default("Title Here")
content String @db.Text
// 1:N relation with Problem
targetId Int
target Problem @relation(references: [id], fields: [targetId], onDelete: Cascade)
problemId Int
problem Problem @relation(references: [id], fields: [problemId], onDelete: Cascade)
// 1:N relation with User
issuerId String
issuer User @relation(references: [id], fields: [issuerId],onDelete: Cascade)
issuerId String
issuer User @relation(references: [id], fields: [issuerId], onDelete: Cascade)
comments ProblemIssueComment[]
@@map("problem_issue")
}
}

model ProblemIssueComment {
id Int @id @default(autoincrement())
content String @db.Text
issueId Int
issue ProblemIssue @relation(fields: [issueId], references: [id], onDelete: Cascade, onUpdate: Cascade)
userId String
user User @relation(fields: [userId],references: [id],onDelete: Cascade, onUpdate: Cascade)
problemId Int
problem Problem @relation(references: [id],fields: [problemId])
@@map("problem_issue_comment")
}
Loading

0 comments on commit dee3425

Please sign in to comment.