Compare commits
1 commit
4aad4d1251
...
e1a6b72c44
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1a6b72c44 |
6 changed files with 4 additions and 26 deletions
|
|
@ -29,7 +29,8 @@ config :logger, :default_formatter,
|
||||||
# Use Jason for JSON parsing in Phoenix
|
# Use Jason for JSON parsing in Phoenix
|
||||||
config :phoenix, :json_library, Jason
|
config :phoenix, :json_library, Jason
|
||||||
|
|
||||||
config :camp_api, :grist, api_key: System.get_env("GRIST_API_KEY")
|
config :camp_api, :grist,
|
||||||
|
api_key: System.get_env("GRIST_API_KEY")
|
||||||
|
|
||||||
# Import environment specific config. This must remain at the bottom
|
# Import environment specific config. This must remain at the bottom
|
||||||
# of this file so it overrides the configuration defined above.
|
# of this file so it overrides the configuration defined above.
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,6 @@ defmodule CampApi.Grist do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp request(method, url) do
|
defp request(method, url) do
|
||||||
Req.request(
|
Req.request(method: method, url: url, headers: [{"authorization", "Bearer " <> Application.fetch_env!(:camp_api, :grist)[:api_key]}])
|
||||||
method: method,
|
|
||||||
url: url,
|
|
||||||
headers: [
|
|
||||||
{"authorization", "Bearer " <> Application.fetch_env!(:camp_api, :grist)[:api_key]}
|
|
||||||
]
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ defmodule CampApi.Grist.Gauge do
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
|
|
||||||
alias CampApi.Grist
|
alias CampApi.Grist
|
||||||
|
|
||||||
|
|
||||||
@gauge_doc "wpwHRjzfdR9A"
|
@gauge_doc "wpwHRjzfdR9A"
|
||||||
@gauge_table "Infos"
|
@gauge_table "Infos"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ defmodule CampApiWeb.GristController do
|
||||||
|
|
||||||
alias CampApi.Grist
|
alias CampApi.Grist
|
||||||
alias CampApi.Grist.Gauge
|
alias CampApi.Grist.Gauge
|
||||||
alias CampApi.Grist.Fundraising
|
|
||||||
|
|
||||||
action_fallback CampApiWeb.FallbackController
|
action_fallback CampApiWeb.FallbackController
|
||||||
|
|
||||||
|
|
@ -12,10 +11,4 @@ defmodule CampApiWeb.GristController do
|
||||||
|
|
||||||
render(conn, :gauge, gauge: gauge)
|
render(conn, :gauge, gauge: gauge)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fundraising(conn, _params) do
|
|
||||||
fundraising = Fundraising.get()
|
|
||||||
|
|
||||||
render(conn, :fundraising, fundraising: fundraising)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,4 @@ defmodule CampApiWeb.GristJSON do
|
||||||
def gauge(%{gauge: gauge}) do
|
def gauge(%{gauge: gauge}) do
|
||||||
%{gauge: gauge}
|
%{gauge: gauge}
|
||||||
end
|
end
|
||||||
|
|
||||||
def fundraising(%{fundraising: fundraising}) do
|
|
||||||
total =
|
|
||||||
fundraising
|
|
||||||
|> Enum.map(fn record -> get_in(record, ["fields", "Montant"]) end)
|
|
||||||
|> Enum.sum()
|
|
||||||
|
|
||||||
%{total: total}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ defmodule CampApiWeb.Router do
|
||||||
pipe_through :api
|
pipe_through :api
|
||||||
|
|
||||||
get "/gauge", GristController, :gauge
|
get "/gauge", GristController, :gauge
|
||||||
|
|
||||||
get "/fundraising", GristController, :fundraising
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Enable LiveDashboard in development
|
# Enable LiveDashboard in development
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue