Created
April 23, 2019 00:53
-
-
Save mazz/010d733bbba4d64502f5653a61af1f85 to your computer and use it in GitHub Desktop.
line 18 and line 19 assignment does not impact outer scope established on line 1 and line 2
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
direction = :asc | |
sorting = :track_number | |
# direction = :desc | |
# sorting = :presented_at | |
media_category = Ecto.Query.from(playlist in Playlist, | |
where: playlist.uuid == ^playlist_uuid, | |
select: playlist.media_category) | |
|> Repo.one | |
|> IO.inspect | |
if media_category == :livestream || | |
media_category == :motivation || | |
media_category == :movie || | |
media_category == :podcast || | |
media_category == :testimony do | |
Logger.info("direction: #{direction} sorting: #{sorting}") | |
direction = :desc | |
sorting = :presented_at | |
else | |
direction = :asc | |
sorting = :track_number | |
end | |
Logger.info("direction: #{direction} sorting: #{sorting}") | |
query = from pl in Playlist, | |
# join: t in MusicTitle, | |
# join: c in Chapter, | |
join: mi in MediaItem, | |
# join: pt in PlaylistTitle, | |
where: pl.uuid == ^pid_uuid, | |
where: mi.playlist_id == pl.id, | |
# where: pl.id == pt.playlist_id, | |
where: mi.language_id == ^language_id, | |
order_by: [{^direction, field(mi, ^sorting)}], |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment