Skip to content

Commit

Permalink
Merge pull request #627 from rfcx/feature/623-create-unique-constrain…
Browse files Browse the repository at this point in the history
…t-between-detection_id-user_id-on-detection_reviews

Add unique constraint to `detection_reviews` table
  • Loading branch information
grindarius authored Jun 6, 2024
2 parents 11726af + 6f08593 commit 5cdb7db
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.3.12 (2024-06-xx)
### Features
* **core**: Endpoint `POST /streams/:streamId/detections/:start/review` now returns the review status and id of the detection that has been reviewed in the call.
* **core**: Create unique constraint of `(detection_id, user_id)` inside `detection_reviews` table.

### Common
* **core**: Remove `jwt-custom` and merge custom into list
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

module.exports = {
up: async (queryInterface) => {
await queryInterface.sequelize.query(`
ALTER TABLE
"public"."detection_reviews"
ADD CONSTRAINT detection_reviews_unique_detection_id_user_id_constraint UNIQUE (detection_id, user_id)
`)
},
down: async (queryInterface) => {
await queryInterface.sequelize.query(`
ALTER TABLE
"public"."detection_reviews"
DROP CONSTRAINT detection_reviews_unique_detection_id_user_id_constraint IF EXISTS
`)
}
}
10 changes: 5 additions & 5 deletions core/detections/review.int.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2844,12 +2844,12 @@ describe('POST /:streamId/detections/:start/review', () => {
})
await DetectionReview.create({
detectionId: detection.toJSON().id,
userId: seedValues.otherUserId,
userId: seedValues.anotherUserId,
status: -1
})
await DetectionReview.create({
detectionId: detection.toJSON().id,
userId: seedValues.otherUserId,
userId: seedValues.differentUserId,
status: -1
})

Expand Down Expand Up @@ -2885,17 +2885,17 @@ describe('POST /:streamId/detections/:start/review', () => {
})
await DetectionReview.create({
detectionId: detection.toJSON().id,
userId: seedValues.otherUserId,
userId: seedValues.anotherUserId,
status: 1
})
await DetectionReview.create({
detectionId: detection.toJSON().id,
userId: seedValues.primaryUserId,
userId: seedValues.differentUserId,
status: -1
})
await DetectionReview.create({
detectionId: detection.toJSON().id,
userId: seedValues.otherUserId,
userId: seedValues.primaryUserId,
status: -1
})

Expand Down

0 comments on commit 5cdb7db

Please sign in to comment.