       {:error, reason}
     end
   end
-
-  # TODO: store feed.last_build_date
-  # defp store_feed(feed_url, feed_attrs) do
-  #   changeset = Feed.changeset(%Feed{}, %{
-  #     title: feed_attrs.title,
-  #     feed_url: feed_url,
-  #     site_url: feed_attrs.url
-  #   })
-  #   Repo.insert(changeset)
-  # end
-
-  # defp import_feed_with_content(feed_url) do
-  #   IO.puts(feed_url)
-  #
-  #   {:ok, json_body}   = fetch(feed_url)
-  #   feed               = parse_feed(json_body)
-  #   {:ok, stored_feed} = store_feed(feed_url, feed)
-  #
-  #   Enum.each(feed.entries, fn(entry) -> store_entry(stored_feed, entry) end)
-  # end
 
   defp store_entry(feed, entry) do
     published = entry[:updated] |> convert_to_ecto_date_time

    Enum.each(parsed_feed.entries, fn(entry) ->
      case store_entry(feed, entry) do
        {:ok, _new_entry} ->
          IO.puts "Updated successfully"
        {:skipping} ->
          IO.puts "Skipping entry"
        {:error, changeset} ->
          IO.puts "Update failed: #{inspect changeset.errors}"
      end
    end)
  end

  # TODO: implement OPML import instead of fixed url list
  # def import_feeds() do
  #   urls = [
  #     "http://heise.de.feedsportal.com/c/35207/f/653902/index.rss",
  #     "http://www.theverge.com/rss/frontpage"
  #   ]
  #
  #   Repo.delete_all(Feed)
  #   Repo.delete_all(Entry)
  #
  #   Enum.each(urls, fn(feed_url) -> import_feed_with_content(feed_url) end)
  # end

  def import_feed(feed_url) do
    case fetch(feed_url) do

    }
  end

  # generate unique guid since in RSS/Atom entries the guid ist not always unique
  defp generate_guid(feed_url, entry_guid, entry_published, entry_title) do
    unique_id_str = "#{feed_url}#{entry_guid}#{entry_published}#{entry_title}"
    :crypto.hash(:sha256, unique_id_str) |> Base.encode16
