Fix duplicated history (#182)
This commit is contained in:
+2
-1
@@ -11,4 +11,5 @@ report.html
|
||||
log.html
|
||||
.expo
|
||||
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");
|
||||
@@ -45,14 +45,13 @@ model Song {
|
||||
}
|
||||
|
||||
model SongHistory {
|
||||
id Int @id @default(autoincrement())
|
||||
song Song @relation(fields: [songID], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
songID Int
|
||||
user User @relation(fields: [userID], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
userID Int
|
||||
score Int
|
||||
difficulties Json
|
||||
|
||||
@@id([songID, userID])
|
||||
}
|
||||
|
||||
model Genre {
|
||||
@@ -88,12 +87,11 @@ model Lesson {
|
||||
}
|
||||
|
||||
model LessonHistory {
|
||||
id Int @id @default(autoincrement())
|
||||
lesson Lesson @relation(fields: [lessonID], references: [id])
|
||||
lessonID Int
|
||||
user User @relation(fields: [userID], references: [id])
|
||||
userID Int
|
||||
|
||||
@@id([lessonID, userID])
|
||||
}
|
||||
|
||||
enum Skill {
|
||||
|
||||
@@ -37,6 +37,40 @@ Create and get an history record
|
||||
[Teardown] Run Keywords DELETE /users/${userID}
|
||||
... 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
|
||||
[Documentation] Create a search history item
|
||||
${userID}= RegisterLogin historyqueryuser
|
||||
|
||||
Reference in New Issue
Block a user