This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove BE sentences from two authors if not yet approved
- Loading branch information
1 parent
c984904
commit 88c2c3c
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
server/migrations/20210708212100-remove-partly-not-yet-approved-be-sentences.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
// Delete sentences from two authors if not approved, as | ||
// bulk uploads covered them and has better quality. | ||
// https://discourse.mozilla.org/t/sentence-collection-for-belarusian-request-for-advice/82150/14 | ||
|
||
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 = "be" | ||
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) | ||
AND (source LIKE "%Максім Гарэцкі" OR source LIKE "%Кузьма Чорны"); | ||
`); | ||
}, | ||
down: () => Promise.resolve(), | ||
}; |