@@ -57,36 +57,33 @@ defmodule AlgoraWeb.HomeLive do
57
57
featured_collabs = list_featured_collabs ( )
58
58
59
59
transactions =
60
- Repo . all (
61
- from tx in Transaction ,
62
- where: tx . type == :credit ,
63
- where: not is_nil ( tx . succeeded_at ) ,
64
- where:
65
- fragment (
66
- "? >= ('USD', 500)::money_with_currency" ,
67
- tx . net_amount
68
- ) ,
69
- join: u in assoc ( tx , :user ) ,
70
- left_join: b in assoc ( tx , :bounty ) ,
71
- left_join: tip in assoc ( tx , :tip ) ,
72
- join: t in Ticket ,
73
- on: t . id == b . ticket_id or t . id == tip . ticket_id ,
74
- join: r in assoc ( t , :repository ) ,
75
- join: o in assoc ( r , :user ) ,
76
- join: ltx in assoc ( tx , :linked_transaction ) ,
77
- join: ltx_user in assoc ( ltx , :user ) ,
78
- select: % {
79
- succeeded_at: tx . succeeded_at ,
80
- net_amount: tx . net_amount ,
81
- bounty_id: b . id ,
82
- tip_id: tip . id ,
83
- user: u ,
84
- ticket: % { t | repository: % { r | user: o } } ,
85
- linked_transaction: % { ltx | user: ltx_user }
86
- } ,
87
- order_by: [ desc: tx . succeeded_at ] ,
88
- limit: 5
60
+ from ( tx in Transaction ,
61
+ where: tx . type == :credit ,
62
+ where: not is_nil ( tx . succeeded_at ) ,
63
+ where: tx . succeeded_at > ago ( 1 , "week" ) ,
64
+ join: u in assoc ( tx , :user ) ,
65
+ left_join: b in assoc ( tx , :bounty ) ,
66
+ left_join: tip in assoc ( tx , :tip ) ,
67
+ join: t in Ticket ,
68
+ on: t . id == b . ticket_id or t . id == tip . ticket_id ,
69
+ join: r in assoc ( t , :repository ) ,
70
+ join: o in assoc ( r , :user ) ,
71
+ join: ltx in assoc ( tx , :linked_transaction ) ,
72
+ join: ltx_user in assoc ( ltx , :user ) ,
73
+ select: % {
74
+ succeeded_at: tx . succeeded_at ,
75
+ net_amount: tx . net_amount ,
76
+ bounty_id: b . id ,
77
+ tip_id: tip . id ,
78
+ user: u ,
79
+ ticket: % { t | repository: % { r | user: o } } ,
80
+ linked_transaction: % { ltx | user: ltx_user }
81
+ } ,
82
+ order_by: [ desc: tx . net_amount ] ,
83
+ limit: 5
89
84
)
85
+ |> Repo . all ( )
86
+ |> Enum . sort_by ( & & 1 . succeeded_at , { :desc , DateTime } )
90
87
91
88
case socket . assigns [ :current_user ] do
92
89
% { handle: handle } = user when is_binary ( handle ) ->
0 commit comments