parser hash fix
This commit is contained in:
parent
b2f9352091
commit
c91f80e23f
2 changed files with 22 additions and 11 deletions
|
|
@ -30,17 +30,24 @@ defmodule Aprsme.DependencyInfo do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp fetch_aprs_sha_from_github do
|
defp fetch_aprs_sha_from_github do
|
||||||
case HTTPoison.get("https://api.github.com/repos/aprsme/aprs/commits/main") do
|
resp = Req.get!("https://api.github.com/repos/aprsme/aprs/commits/main")
|
||||||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
|
body = resp.body
|
||||||
case Jason.decode(body) do
|
sha = body["sha"] || body |> Jason.decode!() |> Access.get("sha")
|
||||||
{:ok, %{"sha" => sha}} -> String.slice(sha, 0, 7)
|
String.slice(sha, 0, 7)
|
||||||
_ -> nil
|
|
||||||
end
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
rescue
|
rescue
|
||||||
_ -> nil
|
_ -> nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def latest_aprs_library_sha do
|
||||||
|
resp = Req.get!("https://api.github.com/repos/aprsme/aprs/commits/main")
|
||||||
|
body = resp.body
|
||||||
|
sha = body["sha"] || body |> Jason.decode!() |> Access.get("sha")
|
||||||
|
String.slice(sha, 0, 7)
|
||||||
|
rescue
|
||||||
|
_ -> nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_latest_aprs_library? do
|
||||||
|
get_aprs_library_sha() == latest_aprs_library_sha()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ defmodule AprsmeWeb.StatusLive.Index do
|
||||||
aprs_status: get_aprs_status(),
|
aprs_status: get_aprs_status(),
|
||||||
version: get_app_version(),
|
version: get_app_version(),
|
||||||
aprs_library_sha: get_aprs_library_sha(),
|
aprs_library_sha: get_aprs_library_sha(),
|
||||||
|
is_latest_aprs_library: Aprsme.DependencyInfo.is_latest_aprs_library?(),
|
||||||
current_time: DateTime.utc_now(),
|
current_time: DateTime.utc_now(),
|
||||||
health_score: calculate_health_score(get_aprs_status())
|
health_score: calculate_health_score(get_aprs_status())
|
||||||
)
|
)
|
||||||
|
|
@ -66,12 +67,15 @@ defmodule AprsmeWeb.StatusLive.Index do
|
||||||
</span>
|
</span>
|
||||||
<span class="text-sm font-mono">
|
<span class="text-sm font-mono">
|
||||||
<a
|
<a
|
||||||
href="https://github.com/aprsme/aprs/commit/{@aprs_library_sha}"
|
href={"https://github.com/aprsme/aprs/commit/#{@aprs_library_sha}"}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="link link-primary"
|
class="link link-primary"
|
||||||
>
|
>
|
||||||
{@aprs_library_sha}
|
{@aprs_library_sha}
|
||||||
</a>
|
</a>
|
||||||
|
<%= if @is_latest_aprs_library do %>
|
||||||
|
<span class="ml-2 text-success font-semibold">Latest ✅</span>
|
||||||
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue