Skip to content

Commit 21de0e5

Browse files
authored
DEV: Clean up amazon translations due to parsing error (#305)
In #203 we introduced a bug for the amazon provider, which was fixed in #297. This commit is a migration to purge the incorrect translations that have been stored. The translation will look like the following as the full response is saved instead of the specific attribute. ``` {translated_text: ... ```
1 parent e1d0887 commit 21de0e5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
class CleanupAmazonTranslations < ActiveRecord::Migration[7.2]
4+
def up
5+
provider =
6+
DB.query_single("SELECT value FROM site_settings WHERE name = 'translator_provider'").first
7+
if provider == "Amazon"
8+
execute <<~SQL
9+
DELETE FROM discourse_translator_post_translations
10+
WHERE translation LIKE '{:translated_text%'
11+
SQL
12+
13+
execute <<~SQL
14+
DELETE FROM discourse_translator_topic_translations
15+
WHERE translation LIKE '{:translated_text%'
16+
SQL
17+
end
18+
end
19+
20+
def down
21+
end
22+
end

0 commit comments

Comments
 (0)