From 0f80e07d7a0a06bd88b6ce3ef0dc9ed7a89624cf Mon Sep 17 00:00:00 2001 From: Michael Kohler Date: Thu, 8 Dec 2022 23:42:47 +0100 Subject: [PATCH] fix: remove unapproved sv-SE Gutenberg sentences --- ...not-yet-approved-sv-sentences-gutenberg.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 server/migrations/20221208220000-remove-not-yet-approved-sv-sentences-gutenberg.js diff --git a/server/migrations/20221208220000-remove-not-yet-approved-sv-sentences-gutenberg.js b/server/migrations/20221208220000-remove-not-yet-approved-sv-sentences-gutenberg.js new file mode 100644 index 00000000..04b5a1ec --- /dev/null +++ b/server/migrations/20221208220000-remove-not-yet-approved-sv-sentences-gutenberg.js @@ -0,0 +1,24 @@ +'use strict'; + +// https://discourse.mozilla.org/t/high-amount-of-low-quality-submissions-in-sentence-collector-makes-reviewing-boring/108368 + +module.exports = { + up: (queryInterface) => { + return queryInterface.sequelize.query(` + WITH IDsToDelete AS (SELECT + Sentences.id + FROM Sentences + LEFT JOIN Votes ON (Votes.sentenceId=Sentences.id) + WHERE + Sentences.localeId = "sv-SE" AND + Sentences.source = "Project Gutenberg, with slight tweaks by me." + GROUP BY Sentences.id + HAVING + COUNT(Votes.approval) < 2 OR + COUNT(Votes.approval) = 2 AND SUM(Votes.approval) = 1 + ) + DELETE FROM Sentences WHERE id IN (SELECT id FROM IDsToDelete); + `); + }, + down: () => Promise.resolve(), +};