Skip to content

Commit 744269b

Browse files
committed
handle not found case
1 parent 0c8f1b0 commit 744269b

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

lib/algora_web/live/claim_live.ex

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,42 @@ defmodule AlgoraWeb.ClaimLive do
2121
target: [repository: [:user], bounties: [:owner]]
2222
])
2323

24-
[primary_claim | _] = claims
24+
case claims do
25+
[] ->
26+
raise(AlgoraWeb.NotFoundError)
2527

26-
prize_pool =
27-
primary_claim.target.bounties
28-
|> Enum.map(& &1.amount)
29-
|> Enum.reduce(Money.zero(:USD, no_fraction_if_integer: true), &Money.add!(&1, &2))
28+
[primary_claim | _] ->
29+
prize_pool =
30+
primary_claim.target.bounties
31+
|> Enum.map(& &1.amount)
32+
|> Enum.reduce(Money.zero(:USD, no_fraction_if_integer: true), &Money.add!(&1, &2))
3033

31-
total_paid =
32-
primary_claim.transactions
33-
|> Enum.filter(&(&1.type == :debit and &1.status == :succeeded))
34-
|> Enum.map(& &1.net_amount)
35-
|> Enum.reduce(Money.zero(:USD, no_fraction_if_integer: true), &Money.add!(&1, &2))
34+
total_paid =
35+
primary_claim.transactions
36+
|> Enum.filter(&(&1.type == :debit and &1.status == :succeeded))
37+
|> Enum.map(& &1.net_amount)
38+
|> Enum.reduce(Money.zero(:USD, no_fraction_if_integer: true), &Money.add!(&1, &2))
3639

37-
source_body_html =
38-
with token when is_binary(token) <- Github.TokenPool.get_token(),
39-
{:ok, source_body_html} <- Github.render_markdown(token, primary_claim.source.description) do
40-
source_body_html
41-
else
42-
_ -> primary_claim.source.description
43-
end
40+
source_body_html =
41+
with token when is_binary(token) <- Github.TokenPool.get_token(),
42+
{:ok, source_body_html} <- Github.render_markdown(token, primary_claim.source.description) do
43+
source_body_html
44+
else
45+
_ -> primary_claim.source.description
46+
end
4447

45-
{:ok,
46-
socket
47-
|> assign(:page_title, primary_claim.source.title)
48-
|> assign(:claims, claims)
49-
|> assign(:primary_claim, primary_claim)
50-
|> assign(:target, primary_claim.target)
51-
|> assign(:source, primary_claim.source)
52-
|> assign(:bounties, primary_claim.target.bounties)
53-
|> assign(:prize_pool, prize_pool)
54-
|> assign(:total_paid, total_paid)
55-
|> assign(:source_body_html, source_body_html)}
48+
{:ok,
49+
socket
50+
|> assign(:page_title, primary_claim.source.title)
51+
|> assign(:claims, claims)
52+
|> assign(:primary_claim, primary_claim)
53+
|> assign(:target, primary_claim.target)
54+
|> assign(:source, primary_claim.source)
55+
|> assign(:bounties, primary_claim.target.bounties)
56+
|> assign(:prize_pool, prize_pool)
57+
|> assign(:total_paid, total_paid)
58+
|> assign(:source_body_html, source_body_html)}
59+
end
5660
end
5761

5862
@impl true

0 commit comments

Comments
 (0)