@@ -56,11 +56,10 @@ defmodule AlgoraWeb.HomeLive do
56
56
featured_devs = Accounts . list_featured_developers ( )
57
57
featured_collabs = list_featured_collabs ( )
58
58
59
- transactions =
59
+ tx_query =
60
60
from ( tx in Transaction ,
61
61
where: tx . type == :credit ,
62
62
where: not is_nil ( tx . succeeded_at ) ,
63
- where: tx . succeeded_at > ago ( 1 , "week" ) ,
64
63
join: u in assoc ( tx , :user ) ,
65
64
left_join: b in assoc ( tx , :bounty ) ,
66
65
left_join: tip in assoc ( tx , :tip ) ,
@@ -71,19 +70,30 @@ defmodule AlgoraWeb.HomeLive do
71
70
join: ltx in assoc ( tx , :linked_transaction ) ,
72
71
join: ltx_user in assoc ( ltx , :user ) ,
73
72
select: % {
73
+ id: tx . id ,
74
74
succeeded_at: tx . succeeded_at ,
75
75
net_amount: tx . net_amount ,
76
76
bounty_id: b . id ,
77
77
tip_id: tip . id ,
78
78
user: u ,
79
79
ticket: % { t | repository: % { r | user: o } } ,
80
80
linked_transaction: % { ltx | user: ltx_user }
81
- } ,
82
- order_by: [ desc: tx . net_amount ] ,
83
- limit: 5
81
+ }
84
82
)
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 } )
87
97
88
98
case socket . assigns [ :current_user ] do
89
99
% { handle: handle } = user when is_binary ( handle ) ->
0 commit comments