@@ -56,11 +56,10 @@ defmodule AlgoraWeb.HomeLive do
5656 featured_devs = Accounts . list_featured_developers ( )
5757 featured_collabs = list_featured_collabs ( )
5858
59- transactions =
59+ tx_query =
6060 from ( tx in Transaction ,
6161 where: tx . type == :credit ,
6262 where: not is_nil ( tx . succeeded_at ) ,
63- where: tx . succeeded_at > ago ( 1 , "week" ) ,
6463 join: u in assoc ( tx , :user ) ,
6564 left_join: b in assoc ( tx , :bounty ) ,
6665 left_join: tip in assoc ( tx , :tip ) ,
@@ -71,19 +70,30 @@ defmodule AlgoraWeb.HomeLive do
7170 join: ltx in assoc ( tx , :linked_transaction ) ,
7271 join: ltx_user in assoc ( ltx , :user ) ,
7372 select: % {
73+ id: tx . id ,
7474 succeeded_at: tx . succeeded_at ,
7575 net_amount: tx . net_amount ,
7676 bounty_id: b . id ,
7777 tip_id: tip . id ,
7878 user: u ,
7979 ticket: % { t | repository: % { r | user: o } } ,
8080 linked_transaction: % { ltx | user: ltx_user }
81- } ,
82- order_by: [ desc: tx . net_amount ] ,
83- limit: 5
81+ }
8482 )
85- |> Repo . all ( )
86- |> Enum . sort_by ( & & 1 . succeeded_at , { :desc , DateTime } )
83+
84+ tx_query =
85+ case Algora.Settings . get_featured_transactions ( ) do
86+ ids when is_list ( ids ) and ids != [ ] ->
87+ where ( tx_query , [ tx ] , tx . id in ^ ids )
88+
89+ _ ->
90+ tx_query
91+ |> where ( [ tx ] , tx . succeeded_at > ago ( 1 , "week" ) )
92+ |> order_by ( [ tx ] , desc: tx . net_amount )
93+ |> limit ( 5 )
94+ end
95+
96+ transactions = tx_query |> Repo . all ( ) |> Enum . sort_by ( & & 1 . succeeded_at , { :desc , DateTime } )
8797
8898 case socket . assigns [ :current_user ] do
8999 % { handle: handle } = user when is_binary ( handle ) ->
0 commit comments