@@ -48,7 +48,7 @@ defmodule AlgoraWeb.Org.BountiesLive do
4848 < div class = "relative flex items-center gap-2.5 text-sm md:text-base " >
4949 < div class = "truncate " > Open</ div >
5050 < span class = { "min-w-[1ch] font-mono #{ if @ current_tab == :open , do: "text-emerald-200" , else: "text-gray-400 group-hover:text-emerald-200" } " } >
51- { @ open_count }
51+ { @ stats . open_bounties_count }
5252 </ span >
5353 </ div >
5454 </ button >
@@ -64,7 +64,7 @@ defmodule AlgoraWeb.Org.BountiesLive do
6464 < div class = "relative flex items-center gap-2.5 text-sm md:text-base " >
6565 < div class = "truncate " > Completed</ div >
6666 < span class = { "min-w-[1ch] font-mono #{ if @ current_tab == :completed , do: "text-emerald-200" , else: "text-gray-400 group-hover:text-emerald-200" } " } >
67- { @ completed_count }
67+ { @ stats . rewarded_bounties_count }
6868 </ span >
6969 </ div >
7070 </ button >
@@ -299,19 +299,16 @@ defmodule AlgoraWeb.Org.BountiesLive do
299299 open_bounties = Bounties . list_bounties ( owner_id: current_org . id , limit: limit , status: :open )
300300 paid_bounties = Bounties . list_bounties ( owner_id: current_org . id , limit: limit , status: :paid )
301301
302- # TODO: fetch stats in one query
303- open_count = length ( open_bounties )
304- paid_count = length ( paid_bounties )
302+ stats = Bounties . fetch_stats ( current_org . id )
305303
306304 { :noreply ,
307305 socket
308306 |> assign ( :current_tab , current_tab )
309- |> assign ( :open_count , open_count )
310- |> assign ( :completed_count , paid_count )
311307 |> assign ( :open_bounties , open_bounties )
312308 |> assign ( :paid_bounties , paid_bounties )
313309 |> assign ( :has_more_open , length ( open_bounties ) >= page_size ( ) )
314310 |> assign ( :has_more_paid , length ( paid_bounties ) >= page_size ( ) )
311+ |> assign ( :stats , stats )
315312 |> assign_bounties ( ) }
316313 end
317314
0 commit comments