Fix duplicated history (#182)

This commit is contained in:
Zoe Roux
2023-04-05 15:30:48 +09:00
committed by GitHub
parent 5ac118efbd
commit fb5e313f6f
4 changed files with 54 additions and 5 deletions
+2 -1
View File
@@ -11,4 +11,5 @@ report.html
log.html log.html
.expo .expo
node_modules/ node_modules/
./front/coverage ./front/coverage
.venv
@@ -0,0 +1,16 @@
/*
Warnings:
- The primary key for the `LessonHistory` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `SongHistory` table will be changed. If it partially fails, the table could be left without primary key constraint.
*/
-- AlterTable
ALTER TABLE "LessonHistory" DROP CONSTRAINT "LessonHistory_pkey",
ADD COLUMN "id" SERIAL NOT NULL,
ADD CONSTRAINT "LessonHistory_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "SongHistory" DROP CONSTRAINT "SongHistory_pkey",
ADD COLUMN "id" SERIAL NOT NULL,
ADD CONSTRAINT "SongHistory_pkey" PRIMARY KEY ("id");
+2 -4
View File
@@ -45,14 +45,13 @@ model Song {
} }
model SongHistory { model SongHistory {
id Int @id @default(autoincrement())
song Song @relation(fields: [songID], references: [id], onDelete: Cascade, onUpdate: Cascade) song Song @relation(fields: [songID], references: [id], onDelete: Cascade, onUpdate: Cascade)
songID Int songID Int
user User @relation(fields: [userID], references: [id], onDelete: Cascade, onUpdate: Cascade) user User @relation(fields: [userID], references: [id], onDelete: Cascade, onUpdate: Cascade)
userID Int userID Int
score Int score Int
difficulties Json difficulties Json
@@id([songID, userID])
} }
model Genre { model Genre {
@@ -88,12 +87,11 @@ model Lesson {
} }
model LessonHistory { model LessonHistory {
id Int @id @default(autoincrement())
lesson Lesson @relation(fields: [lessonID], references: [id]) lesson Lesson @relation(fields: [lessonID], references: [id])
lessonID Int lessonID Int
user User @relation(fields: [userID], references: [id]) user User @relation(fields: [userID], references: [id])
userID Int userID Int
@@id([lessonID, userID])
} }
enum Skill { enum Skill {
+34
View File
@@ -37,6 +37,40 @@ Create and get an history record
[Teardown] Run Keywords DELETE /users/${userID} [Teardown] Run Keywords DELETE /users/${userID}
... AND DELETE /song/${song.body.id} ... AND DELETE /song/${song.body.id}
Create and get a duplicated history record
[Documentation] Create an history item
&{song}= POST
... /song
... {"name": "Mama mia", "difficulties": {}, "midiPath": "/musics/Beethoven-125-4.midi", "musicXmlPath": "/musics/Beethoven-125-4.mxl"}
Output
${userID}= RegisterLogin wowuser
&{history}= POST
... /history
... { "userID": ${userID}, "songID": ${song.body.id}, "score": 55, "difficulties": {} }
Output
Integer response status 201
&{history2}= POST
... /history
... { "userID": ${userID}, "songID": ${song.body.id}, "score": 65, "difficulties": {} }
Output
Integer response status 201
&{res}= GET /history
Output
Integer response status 200
Array response body
Integer $[0].userID ${userID}
Integer $[0].songID ${song.body.id}
Integer $[0].score 55
Integer $[1].userID ${userID}
Integer $[1].songID ${song.body.id}
Integer $[1].score 65
[Teardown] Run Keywords DELETE /users/${userID}
... AND DELETE /song/${song.body.id}
Create and get a search history record Create and get a search history record
[Documentation] Create a search history item [Documentation] Create a search history item
${userID}= RegisterLogin historyqueryuser ${userID}= RegisterLogin historyqueryuser