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
|
||||
|
||||
defp fetch_aprs_sha_from_github do
|
||||
case HTTPoison.get("https://api.github.com/repos/aprsme/aprs/commits/main") do
|
||||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
|
||||
case Jason.decode(body) do
|
||||
{:ok, %{"sha" => sha}} -> String.slice(sha, 0, 7)
|
||||
_ -> nil
|
||||
end
|
||||
|
||||
_ ->
|
||||
nil
|
||||
end
|
||||
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 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
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ defmodule AprsmeWeb.StatusLive.Index do
|
|||
aprs_status: get_aprs_status(),
|
||||
version: get_app_version(),
|
||||
aprs_library_sha: get_aprs_library_sha(),
|
||||
is_latest_aprs_library: Aprsme.DependencyInfo.is_latest_aprs_library?(),
|
||||
current_time: DateTime.utc_now(),
|
||||
health_score: calculate_health_score(get_aprs_status())
|
||||
)
|
||||
|
|
@ -66,12 +67,15 @@ defmodule AprsmeWeb.StatusLive.Index do
|
|||
</span>
|
||||
<span class="text-sm font-mono">
|
||||
<a
|
||||
href="https://github.com/aprsme/aprs/commit/{@aprs_library_sha}"
|
||||
href={"https://github.com/aprsme/aprs/commit/#{@aprs_library_sha}"}
|
||||
target="_blank"
|
||||
class="link link-primary"
|
||||
>
|
||||
{@aprs_library_sha}
|
||||
</a>
|
||||
<%= if @is_latest_aprs_library do %>
|
||||
<span class="ml-2 text-success font-semibold">Latest ✅</span>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue