@@ -2,39 +2,44 @@ defmodule AlgoraWeb.ClaimLive do
2
2
@ moduledoc false
3
3
use AlgoraWeb , :live_view
4
4
5
+ import Ecto.Query
6
+
5
7
alias Algora.Bounties.Claim
6
8
alias Algora.Github
7
9
alias Algora.Repo
8
10
9
11
@ impl true
10
- def mount ( % { "id" => id } , _session , socket ) do
11
- { :ok , claim } = Repo . fetch ( Claim , id )
12
-
13
- claim =
14
- Repo . preload ( claim , [
12
+ def mount ( % { "group_id" => group_id } , _session , socket ) do
13
+ claims =
14
+ from ( c in Claim , where: c . group_id == ^ group_id )
15
+ |> order_by ( desc: :group_share )
16
+ |> Repo . all ( )
17
+ |> Repo . preload ( [
15
18
:user ,
16
19
source: [ repository: [ :user ] ] ,
17
20
target: [ repository: [ :user ] , bounties: [ :owner ] ]
18
21
] )
19
22
20
- { :ok , prize_pool } = claim . target . bounties |> Enum . map ( & & 1 . amount ) |> Money . sum ( )
23
+ [ primary_claim | _ ] = claims
24
+
25
+ { :ok , prize_pool } = primary_claim . target . bounties |> Enum . map ( & & 1 . amount ) |> Money . sum ( )
21
26
22
27
source_body_html =
23
28
with token when is_binary ( token ) <- Github.TokenPool . get_token ( ) ,
24
- { :ok , source_body_html } <- Github . render_markdown ( token , claim . source . description ) do
29
+ { :ok , source_body_html } <- Github . render_markdown ( token , primary_claim . source . description ) do
25
30
source_body_html
26
31
else
27
- _ -> claim . source . description
32
+ _ -> primary_claim . source . description
28
33
end
29
34
30
35
{ :ok ,
31
36
socket
32
- |> assign ( :page_title , "Claim Details" )
33
- |> assign ( :claim , claim )
34
- |> assign ( :target , claim . target )
35
- |> assign ( :source , claim . source )
36
- |> assign ( :user , claim . user )
37
- |> assign ( :bounties , claim . target . bounties )
37
+ |> assign ( :page_title , primary_claim . source . title )
38
+ |> assign ( :claims , claims )
39
+ |> assign ( :primary_claim , primary_claim )
40
+ |> assign ( :target , primary_claim . target )
41
+ |> assign ( :source , primary_claim . source )
42
+ |> assign ( :bounties , primary_claim . target . bounties )
38
43
|> assign ( :prize_pool , prize_pool )
39
44
|> assign ( :source_body_html , source_body_html ) }
40
45
end
@@ -76,15 +81,19 @@ defmodule AlgoraWeb.ClaimLive do
76
81
<%!-- Claimer Info --%>
77
82
< . card >
78
83
< . card_header >
79
- < div class = "flex items-center gap-4 " >
80
- < . avatar >
81
- < . avatar_image src = { @ user . avatar_url } />
82
- < . avatar_fallback > { String . first ( @ user . name ) } </ . avatar_fallback >
83
- </ . avatar >
84
- < div >
85
- < p class = "font-medium " > { @ user . name } </ p >
86
- < p class = "text-sm text-muted-foreground " > @{ @ user . handle } </ p >
87
- </ div >
84
+ < div class = "grid grid-cols-1 sm:grid-cols-3 " >
85
+ <%= for claim <- @ claims do %>
86
+ < div class = "flex items-center gap-4 " >
87
+ < . avatar >
88
+ < . avatar_image src = { claim . user . avatar_url } />
89
+ < . avatar_fallback > { String . first ( claim . user . name ) } </ . avatar_fallback >
90
+ </ . avatar >
91
+ < div >
92
+ < p class = "font-medium " > { claim . user . name } </ p >
93
+ < p class = "text-sm text-muted-foreground " > @{ claim . user . handle } </ p >
94
+ </ div >
95
+ </ div >
96
+ <% end %>
88
97
</ div >
89
98
</ . card_header >
90
99
< . card_content >
@@ -126,15 +135,15 @@ defmodule AlgoraWeb.ClaimLive do
126
135
< div class = "space-y-2 " >
127
136
< div class = "flex justify-between text-sm " >
128
137
< span class = "text-muted-foreground " > Status</ span >
129
- < span > { @ claim . status |> to_string ( ) |> String . capitalize ( ) } </ span >
138
+ < span > { @ primary_claim . status |> to_string ( ) |> String . capitalize ( ) } </ span >
130
139
</ div >
131
140
< div class = "flex justify-between text-sm " >
132
141
< span class = "text-muted-foreground " > Submitted</ span >
133
- < span > { Calendar . strftime ( @ claim . inserted_at , "%B %d, %Y" ) } </ span >
142
+ < span > { Calendar . strftime ( @ primary_claim . inserted_at , "%B %d, %Y" ) } </ span >
134
143
</ div >
135
144
< div class = "flex justify-between text-sm " >
136
145
< span class = "text-muted-foreground " > Last Updated</ span >
137
- < span > { Calendar . strftime ( @ claim . updated_at , "%B %d, %Y" ) } </ span >
146
+ < span > { Calendar . strftime ( @ primary_claim . updated_at , "%B %d, %Y" ) } </ span >
138
147
</ div >
139
148
</ div >
140
149
</ . card_content >
0 commit comments