|
|
@@ -41,21 +41,32 @@ defmodule Vaccins.Queries do
|
|
|
}
|
|
|
end
|
|
|
|
|
|
- def analyze_result(%{total: 0}), do: :no_availability
|
|
|
+ def analyze_result(%{total: 0}), do: {:error, :no_availability}
|
|
|
+
|
|
|
+ def analyze_result(%{total: t, availabilities: avail_list}) when t > 0 do
|
|
|
+ {:ok,
|
|
|
+ avail_list
|
|
|
+ |> Enum.reject(&(&1.slots |> Enum.empty?()))
|
|
|
+ |> Enum.map(& &1.slots)
|
|
|
+ |> Enum.concat()
|
|
|
+ |> Enum.map(&(&1 |> Map.take([:start_date, :end_date])))}
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
def valid_queries(),
|
|
|
- do: %{
|
|
|
- id: :olympe,
|
|
|
- availability_query:
|
|
|
- Doctolib.new(
|
|
|
- visit_motive_ids: 2_549_915,
|
|
|
- agenda_ids:
|
|
|
- "434477-434486-434466-434472-440075-440077-440078-415625-434490-462178-462452-433984-462177-433604-433601-415628-440074-433997-434489-440076",
|
|
|
- practice_ids: 164_922,
|
|
|
- limit: 7
|
|
|
- ),
|
|
|
- booking_page:
|
|
|
- "https://partners.doctolib.fr/centre-de-sante/fontenay-sous-bois/centre-de-vaccination-covid-19-fontenay-sous-bois?pid=practice-180541"
|
|
|
- }
|
|
|
+ do: [
|
|
|
+ %{
|
|
|
+ id: :olympe,
|
|
|
+ availability_query:
|
|
|
+ Doctolib.new(
|
|
|
+ visit_motive_ids: 2_549_915,
|
|
|
+ agenda_ids:
|
|
|
+ "434477-434486-434466-434472-440075-440077-440078-415625-434490-462178-462452-433984-462177-433604-433601-415628-440074-433997-434489-440076",
|
|
|
+ practice_ids: 164_922,
|
|
|
+ limit: 7
|
|
|
+ ),
|
|
|
+ booking_page:
|
|
|
+ "https://partners.doctolib.fr/centre-de-sante/fontenay-sous-bois/centre-de-vaccination-covid-19-fontenay-sous-bois?pid=practice-180541"
|
|
|
+ }
|
|
|
+ ]
|
|
|
end
|