+ def filter_reachable([]), do: []
+
+ def filter_reachable(urls) when is_list(urls) do
+ hosts =
+ urls
+ |> Enum.map(&(&1 && host(&1)))
+ |> Enum.filter(&(to_string(&1) != ""))
+
+ unreachable_hosts =
+ Repo.all(
+ from(i in Instance,
+ where:
+ i.host in ^hosts and
+ i.unreachable_since <= ^Instances.reachability_datetime_threshold(),
+ select: i.host
+ )
+ )
+
+ Enum.filter(urls, &(&1 && host(&1) not in unreachable_hosts))
+ end
+
+ def reachable?(url) when is_binary(url) do