   plug :scrub_params, "podcast" when action in [:create, :update]
 
   def orphans(conn, _params) do
-    podcast_ids = Repo.all(from a in "categories_podcasts", group_by: a.podcast_id,
-                                                            select: a.podcast_id)
+    podcast_ids = from(a in "categories_podcasts", group_by: a.podcast_id,
+                                                   select: a.podcast_id)
+                  |> Repo.all
 
-    podcasts = Repo.all(from p in Podcast, where: not p.id in ^podcast_ids)
+    podcasts = from(p in Podcast, where: not p.id in ^podcast_ids)
+               |> Repo.all
 
     render(conn, "orphans.html", podcasts: podcasts)
   end


  def delta_import_all(conn, _params) do
    current_user = conn.assigns.current_user
    podcasts = Repo.all(from p in Podcast, where: p.updated_at <= ^ten_hours_ago and
                                                  (is_nil(p.update_paused) or p.update_paused == false),
                                           order_by: [asc: :updated_at])

    for podcast <- podcasts do
      notification = case Pan.Parser.Podcast.delta_import(podcast.id) do

            type: "danger",
            user_name: current_user.name}
      end

      Pan.Endpoint.broadcast "mailboxes:" <> Integer.to_string(current_user.id),
                             "notification", notification
    end

    conn
