Skip to content

Commit

Permalink
Refactor the code to remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
grindarius committed Jun 7, 2024
1 parent aae814b commit 74c7ce9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { QueryTypes } = require('sequelize')
const Sequelize = require('sequelize')

module.exports = {
up: async (queryInterface) => {
Expand All @@ -10,11 +10,11 @@ module.exports = {
MIN(id) as first_id,
detection_id,
user_id,
count(*)
from detection_reviews
COUNT(*)
FROM detection_reviews
GROUP BY detection_id, user_id
HAVING COUNT(*) > 1;
`, { type: QueryTypes.RAW })
`, { type: Sequelize.QueryTypes.SELECT })

for (const record of recordsWithDuplicates) {
await queryInterface.sequelize.query(`
Expand Down

0 comments on commit 74c7ce9

Please sign in to comment.