More readable SQL query.
This commit is contained in:
parent
3dbec2c285
commit
b25319f92b
|
@ -38,9 +38,13 @@ class MembersFinder
|
||||||
<<~SQL
|
<<~SQL
|
||||||
SELECT DISTINCT ON (user_id, invite_email) member_union.*
|
SELECT DISTINCT ON (user_id, invite_email) member_union.*
|
||||||
FROM (#{union.to_sql}) AS member_union
|
FROM (#{union.to_sql}) AS member_union
|
||||||
ORDER BY
|
ORDER BY user_id,
|
||||||
user_id, invite_email,
|
invite_email,
|
||||||
CASE WHEN type = 'ProjectMember' THEN 1 WHEN type = 'GroupMember' THEN 2 ELSE 3 END
|
CASE
|
||||||
|
WHEN type = 'ProjectMember' THEN 1
|
||||||
|
WHEN type = 'GroupMember' THEN 2
|
||||||
|
ELSE 3
|
||||||
|
END
|
||||||
SQL
|
SQL
|
||||||
else
|
else
|
||||||
# Older versions of MySQL do not support window functions (and DISTINCT ON is postgres-specific).
|
# Older versions of MySQL do not support window functions (and DISTINCT ON is postgres-specific).
|
||||||
|
|
Loading…
Reference in New Issue