Repository: Automattic/pocket-casts-android
File: modules/services/model/src/main/java/au/com/shiftyjelly/pocketcasts/models/db/dao/PlaylistDao.kt (Kotlin)

Code before:
        JOIN podcasts AS podcast ON podcast.uuid IS playlistEpisode.podcast_uuid
        WHERE
          playlist.uuid IS :playlistId
          AND podcastEpisode.archived IS 0
        ORDER BY
          -- newest to oldest
          CASE WHEN playlist.sortId IS 0 THEN podcastEpisode.published_date END DESC,
          CASE WHEN playlist.sortId IS 0 THEN podcastEpisode.added_date END DESC,
          -- oldest to newest
          CASE WHEN playlist.sortId IS 1 THEN podcastEpisode.published_date END ASC,
          CASE WHEN playlist.sortId IS 1 THEN podcastEpisode.added_date END ASC,
          -- shortest to longest
          CASE WHEN playlist.sortId IS 2 THEN podcastEpisode.duration END ASC,
          CASE WHEN playlist.sortId IS 2 THEN podcastEpisode.added_date END DESC,
          -- longest to shortest
          CASE WHEN playlist.sortId IS 3 THEN podcastEpisode.duration END DESC,
          CASE WHEN playlist.sortId IS 4 THEN podcastEpisode.added_date END DESC
        LIMIT 4
    """,
    )
    abstract fun observeManualPlaylistPodcasts(playlistId: String): Flow<List<String>>

    @Query(
        """
        SELECT
            -- plaulist episode columns
            manual_episode.playlist_uuid AS m_playlist_uuid,
            manual_episode.episode_uuid AS m_episode_uuid,
            manual_episode.podcast_uuid AS m_podcast_uuid,
            manual_episode.title AS m_title,
            manual_episode.added_at AS m_added_at,
            manual_episode.published_at AS m_published_at,
            manual_episode.download_url AS m_download_url,
            manual_episode.episode_slug AS m_episode_slug,
            manual_episode.podcast_slug AS m_podcast_slug,
            manual_episode.sort_position AS m_sort_position,
            manual_episode.is_synced AS m_is_synced,
            -- podcast episode columns
            podcast_episode.uuid AS p_uuid,
            podcast_episode.episode_description AS p_episode_description,
            podcast_episode.published_date AS p_published_date,
            podcast_episode.title AS p_title,
            podcast_episode.size_in_bytes AS p_size_in_bytes,
            podcast_episode.episode_status AS p_episode_status,
            podcast_episode.file_type AS p_file_type,
            podcast_episode.duration AS p_duration,
            podcast_episode.download_url AS p_download_url,
            podcast_episode.downloaded_file_path AS p_downloaded_file_path,
            podcast_episode.downloaded_error_details AS p_downloaded_error_details,
            podcast_episode.play_error_details AS p_play_error_details,
            podcast_episode.played_up_to AS p_played_up_to,

Review comment (suggestion):
```suggestion
            -- playlist episode columns
```

Code after:
        JOIN podcasts AS podcast ON podcast.uuid IS playlistEpisode.podcast_uuid
        WHERE
          playlist.uuid IS :playlistId
          AND podcastEpisode.archived IS 0
        ORDER BY
          -- newest to oldest
          CASE WHEN playlist.sortId IS 0 THEN podcastEpisode.published_date END DESC,
          CASE WHEN playlist.sortId IS 0 THEN podcastEpisode.added_date END DESC,
          -- oldest to newest
          CASE WHEN playlist.sortId IS 1 THEN podcastEpisode.published_date END ASC,
          CASE WHEN playlist.sortId IS 1 THEN podcastEpisode.added_date END ASC,
          -- shortest to longest
          CASE WHEN playlist.sortId IS 2 THEN podcastEpisode.duration END ASC,
          CASE WHEN playlist.sortId IS 2 THEN podcastEpisode.added_date END DESC,
          -- longest to shortest
          CASE WHEN playlist.sortId IS 3 THEN podcastEpisode.duration END DESC,
          CASE WHEN playlist.sortId IS 4 THEN podcastEpisode.added_date END DESC
        LIMIT 4
    """,
    )
    abstract fun observeManualPlaylistPodcasts(playlistId: String): Flow<List<String>>

    @Query(
        """
        SELECT
            -- playlist episode columns
            manual_episode.playlist_uuid AS m_playlist_uuid,
            manual_episode.episode_uuid AS m_episode_uuid,
            manual_episode.podcast_uuid AS m_podcast_uuid,
            manual_episode.title AS m_title,
            manual_episode.added_at AS m_added_at,
            manual_episode.published_at AS m_published_at,
            manual_episode.download_url AS m_download_url,
            manual_episode.episode_slug AS m_episode_slug,
            manual_episode.podcast_slug AS m_podcast_slug,
            manual_episode.sort_position AS m_sort_position,
            manual_episode.is_synced AS m_is_synced,
            -- podcast episode columns
            podcast_episode.uuid AS p_uuid,
            podcast_episode.episode_description AS p_episode_description,
            podcast_episode.published_date AS p_published_date,
            podcast_episode.title AS p_title,
            podcast_episode.size_in_bytes AS p_size_in_bytes,
            podcast_episode.episode_status AS p_episode_status,
            podcast_episode.file_type AS p_file_type,
            podcast_episode.duration AS p_duration,
            podcast_episode.download_url AS p_download_url,
            podcast_episode.downloaded_file_path AS p_downloaded_file_path,
            podcast_episode.downloaded_error_details AS p_downloaded_error_details,
            podcast_episode.play_error_details AS p_play_error_details,
            podcast_episode.played_up_to AS p_played_up_to,