Localize examples
This commit is contained in:
parent
51bf603036
commit
702dadfa00
26
main.rb
26
main.rb
|
@ -60,7 +60,7 @@ private
|
|||
<<~SQL
|
||||
SELECT id
|
||||
FROM languages
|
||||
WHERE code = $1
|
||||
WHERE code = $1 OR code = 'en'
|
||||
ORDER BY
|
||||
(CASE WHEN code != 'en' THEN 1 ELSE 2 END) ASC
|
||||
LIMIT 1
|
||||
|
@ -220,7 +220,7 @@ public
|
|||
word_id = Integer word_id
|
||||
|
||||
left_lang_id = 5 # Georgian
|
||||
right_lang_id = 2 # Russian
|
||||
right_lang_id = locale_id
|
||||
|
||||
lang_order = left_lang_id < right_lang_id ? 'ASC' : 'DESC'
|
||||
|
||||
|
@ -262,13 +262,23 @@ public
|
|||
SQL
|
||||
),
|
||||
[word_id, left_lang_id, right_lang_id],
|
||||
).map do |row|
|
||||
).filter_map do |row|
|
||||
example_id = Integer(row['example_id'])
|
||||
|
||||
left_id = Integer(row['ids'].first) if row['ids'].size > 0
|
||||
right_id = Integer(row['ids'].last) if row['ids'].size > 1
|
||||
|
||||
left = String(row['values'].first).strip.freeze if row['values'].size > 0
|
||||
right = String(row['values'].last).strip.freeze if row['values'].size > 1
|
||||
|
||||
next if left_id.nil? || left.nil?
|
||||
|
||||
{
|
||||
example_id: Integer(row['example_id']),
|
||||
left_id: Integer(row['ids'].first),
|
||||
right_id: Integer(row['ids'].last),
|
||||
left: String(row['values'].first).strip.freeze,
|
||||
right: String(row['values'].last).strip.freeze,
|
||||
example_id: example_id,
|
||||
left_id: left_id,
|
||||
right_id: right_id,
|
||||
left: left,
|
||||
right: right,
|
||||
highlights: [],
|
||||
}.freeze
|
||||
end.freeze
|
||||
|
|
Loading…
Reference in New Issue