Selaa lähdekoodia

Add geographic location to location store

theenglishway (time) 4 vuotta sitten
vanhempi
commit
1a68a93b47

+ 5 - 2
lib/vaccins/location_store.ex

@@ -6,6 +6,7 @@ defmodule Vaccins.LocationStore do
     defstruct [
       :id,
       :name,
+      :location,
       :availability_query,
       :booking_page,
       :provider,
@@ -54,6 +55,7 @@ defmodule Vaccins.LocationStore do
 
     embedded_schema do
       field(:name, :string)
+      field(:location, :string)
       field(:booking_page, :string)
       field(:raw_query, :string)
     end
@@ -62,8 +64,8 @@ defmodule Vaccins.LocationStore do
     def changeset(location \\ %__MODULE__{}, attrs),
       do:
         location
-        |> cast(attrs, [:name, :booking_page, :raw_query])
-        |> validate_required([:name, :booking_page, :raw_query])
+        |> cast(attrs, [:name, :location, :booking_page, :raw_query])
+        |> validate_required([:name, :location, :booking_page, :raw_query])
 
     def to_query_params(%__MODULE__{raw_query: raw}) do
       raw
@@ -115,6 +117,7 @@ defmodule Vaccins.LocationStore do
            processed <-
              %Location{
                name: raw_location.name,
+               location: raw_location.location,
                booking_page: raw_location.booking_page,
                availability_query_params: raw_location |> LocationRaw.to_query_params(),
                provider: Doctolib

+ 6 - 2
lib/vaccins_web/live/index_live.html.leex

@@ -7,12 +7,16 @@
     <%= text_input f, :name %>
     <%= error_tag f, :name %>
 
+    <%= label f, :location %>
+    <%= text_input f, :location %>
+    <%= error_tag f, :location %>
+
     <%= label f, :booking_page %>
-    <%= text_input f, :booking_page %>
+    <%= url_input f, :booking_page %>
     <%= error_tag f, :booking_page %>
 
     <%= label f, :raw_query %>
-    <%= text_input f, :raw_query %>
+    <%= url_input f, :raw_query %>
     <%= error_tag f, :raw_query %>
 
     <%= submit "send" %>

+ 4 - 2
lib/vaccins_web/live/location_component.ex

@@ -48,8 +48,10 @@ defmodule VaccinsWeb.LocationComponent do
   def render(assigns) do
     ~L"""
       <dl class="location">
-        <dt>id</dt>
-        <dd><%= @location.id %></dd>
+        <dt>name</dt>
+        <dd><%= @location.name %></dd>
+        <dt>location</dt>
+        <dd><%= @location.location %></dd>
         <dt>Status (<%= if @last_refresh_date, do: @last_refresh_date |> Time.to_string() %>) </dt>
         <dd>
           <%= cond do %>

+ 4 - 0
location_store.json

@@ -9,6 +9,7 @@
     },
     "booking_page": "https://partners.doctolib.fr/centre-de-sante/fontenay-sous-bois/centre-de-vaccination-covid-19-fontenay-sous-bois?pid=practice-180541",
     "id": "Centre de Vaccination - Salle Olympe de Gouges",
+    "location": null,
     "name": "Centre de Vaccination - Salle Olympe de Gouges",
     "provider": "Elixir.Vaccins.Queries.Doctolib"
   },
@@ -22,6 +23,7 @@
     },
     "booking_page": "https://www.doctolib.fr/hopital-public/saint-mande/centre-de-vaccination-covid-19-hopital-des-armees-begin",
     "id": "Centre de vaccination Covid-19 - Hôpital des Armées Bégin",
+    "location": null,
     "name": "Centre de vaccination Covid-19 - Hôpital des Armées Bégin",
     "provider": "Elixir.Vaccins.Queries.Doctolib"
   },
@@ -35,6 +37,7 @@
     },
     "booking_page": "https://partners.doctolib.fr/centre-de-sante/fontenay-sous-bois/centre-de-vaccination-covid-19-fontenay-sous-bois?pid=practice-180541&enable_cookies_consent=1",
     "id": "Hotel de ville de Fontenay-sous-Bois",
+    "location": null,
     "name": "Hotel de ville de Fontenay-sous-Bois",
     "provider": "Elixir.Vaccins.Queries.Doctolib"
   },
@@ -48,6 +51,7 @@
     },
     "booking_page": "https://www.doctolib.fr/pharmacie/paris/pharmacie-centrale-des-pyrenees",
     "id": "Pharmacie centrale des Pyrénées - iPharm - Paris XXe",
+    "location": null,
     "name": "Pharmacie centrale des Pyrénées - iPharm - Paris XXe",
     "provider": "Elixir.Vaccins.Queries.Doctolib"
   }