Skip to content

Commit

Permalink
Fix signs erroneously sorted after compounds that include them
Browse files Browse the repository at this point in the history
  • Loading branch information
r-tae committed Jun 18, 2024
1 parent f78d70a commit 672f400
Showing 1 changed file with 165 additions and 0 deletions.
165 changes: 165 additions & 0 deletions priv/repo/migrations/20240618140952_fix_sign_sorting_errors.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
defmodule Signbank.Repo.Migrations.FixSignSortingErrors do
use Ecto.Migration

def change do
execute(
"""
create or replace view sign_order as with s as (select id, row_number() over (order by
coalesce(
array_position(
ARRAY[ 'relaxed', 'round', 'okay',
'point', 'hook', 'two', 'kneel', 'perth',
'spoon', 'letter_n', 'wish', 'three',
'mother', 'letter_m', 'four', 'spread',
'ball', 'flat', 'thick', 'cup', 'good',
'bad', 'gun', 'buckle', 'letter_c',
'small', 'seven_old', 'eight', 'nine',
'fist', 'soon', 'ten', 'write', 'salt',
'duck', 'middle', 'rude', 'ambivalent',
'love', 'animal', 'queer' ] :: varchar[],
phonology ->> 'dominant_initial_handshape'
),
null
),
coalesce(
array_position(
ARRAY[ 'relaxed', 'round', 'okay',
'point', 'hook', 'two', 'kneel', 'perth',
'spoon', 'letter_n', 'wish', 'three',
'mother', 'letter_m', 'four', 'spread',
'ball', 'flat', 'thick', 'cup', 'good',
'bad', 'gun', 'buckle', 'letter_c',
'small', 'seven_old', 'eight', 'nine',
'fist', 'soon', 'ten', 'write', 'salt',
'duck', 'middle', 'rude', 'ambivalent',
'love', 'animal', 'queer' ] :: varchar[],
phonology ->> 'subordinate_initial_handshape'
),
0
),
coalesce(
array_position(
ARRAY[ 'top_head', 'forehead', 'temple',
'eye', 'cheekbone', 'nose', 'whole_face',
'ear_or_side_head', 'cheek', 'mouth_or_lips',
'chin', 'neck', 'shoulder', 'high_neutral_space',
'chest', 'neutral_space', 'stomach',
'low_neutral_space', 'waist', 'below_waist',
'upper_arm', 'elbow', 'pronated_forearm',
'supinated_forearm', 'pronated_wrist',
'supinated_wrist', 'palm' ] :: varchar[],
phonology ->> 'initial_primary_location'
),
null
),
coalesce( -- #############check me#######################
array_position(
ARRAY['up_left','up','up_right','up_away',
'up_towards','left','away','away_left',
'away_right','away_down','towards','down',
'right'] :: varchar[], phonology ->> 'dominant_initial_finger_hand_orientation'
),
null
),
coalesce(
array_position(
ARRAY[ 'towards', 'left', 'away', 'up',
'down', 'right' ] :: varchar[], phonology ->> 'dominant_initial_palm_orientation'
),
null
),
coalesce(
array_position(
ARRAY['up_left','up','up_right','up_away',
'up_towards','left','away','away_left',
'away_right','away_down','towards','down',
'right'] :: varchar[], phonology ->> 'subordinate_initial_finger_hand_orientation'
),
null
),
coalesce(
array_position(
ARRAY[ 'towards', 'left', 'away', 'up',
'down', 'right' ] :: varchar[], phonology ->> 'subordinate_initial_palm_orientation'
),
null
),
coalesce(
array_position(
ARRAY['up_left','up','up_right','up_away',
'up_towards','left','away','away_left',
'away_right','away_down','towards','down',
'right'] :: varchar[], phonology ->> 'dominant_final_finger_hand_orientation'
),
null
),
coalesce(
array_position(
ARRAY[ 'palm', 'back', 'radial', 'ulnar',
'fingertips', 'wrist', 'forearm',
'elbow' ] :: varchar[], phonology ->> 'dominant_initial_interacting_handpart'
),
null
),
coalesce(
array_position(
ARRAY[ 'palm', 'back', 'radial', 'ulnar',
'fingertips', 'wrist', 'forearm',
'elbow' ] :: varchar[], phonology ->> 'subordinate_initial_interacting_handpart'
),
null
),
coalesce(
array_position(
ARRAY[ 'none', 'up', 'down', 'up_and_down',
'left', 'right', 'side_to_side',
'away', 'towards', 'to_and_fro' ] :: varchar[],
phonology ->> 'movement_direction'
),
0
),
coalesce(
array_position(
ARRAY[ 'none', 'straight', 'diagonal',
'arc', 'curved', 'wavy', 'zig_zag',
'circular', 'spiral' ] :: varchar[],
phonology ->> 'movement_path'
),
0
),
coalesce(
array_position(
ARRAY[false, true] :: varchar[], phonology ->> 'movement_repeated'
),
0
),
coalesce(
array_position(
ARRAY[ 'relaxed', 'round', 'okay',
'point', 'hook', 'two', 'kneel', 'perth',
'spoon', 'letter_n', 'wish', 'three',
'mother', 'letter_m', 'four', 'spread',
'ball', 'flat', 'thick', 'cup', 'good',
'bad', 'gun', 'buckle', 'letter_c',
'small', 'seven_old', 'eight', 'nine',
'fist', 'soon', 'ten', 'write', 'salt',
'duck', 'middle', 'rude', 'ambivalent',
'love', 'animal', 'queer' ] :: varchar[],
phonology ->> 'dominant_final_handshape'
),
0
),
morphology ->> 'compound_of' nulls first,
sense_number,
id_gloss
) ordernum from signs)
select
s.id "sign_id",
lag(s.id, 1) over (order by ordernum) "previous",
lead(s.id, 1) over (order by ordernum) "next"
from s;
""",
"drop view sign_order"
)
end
end

0 comments on commit 672f400

Please sign in to comment.