Skip to content

Commit 756d056

Browse files
committed
fix: refine home page transaction statistics queries
1 parent 058fd1f commit 756d056

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/algora_web/live/home_live.ex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ defmodule AlgoraWeb.HomeLive do
196196
subtotal =
197197
Repo.one(
198198
from t in Transaction,
199-
where: t.type == :credit and t.status == :succeeded,
199+
where: t.type == :credit,
200+
where: t.status == :succeeded,
201+
where: not is_nil(t.linked_transaction_id),
200202
select: sum(t.net_amount)
201203
) || Money.new(0, :USD)
202204

@@ -209,6 +211,7 @@ defmodule AlgoraWeb.HomeLive do
209211
from t in Transaction,
210212
where: t.type == :credit,
211213
where: t.status == :succeeded,
214+
where: not is_nil(t.linked_transaction_id),
212215
where: not is_nil(t.bounty_id),
213216
select: count(fragment("DISTINCT ?", t.bounty_id))
214217
) || 0
@@ -218,6 +221,7 @@ defmodule AlgoraWeb.HomeLive do
218221
from t in Transaction,
219222
where: t.type == :credit,
220223
where: t.status == :succeeded,
224+
where: not is_nil(t.linked_transaction_id),
221225
where: not is_nil(t.tip_id),
222226
select: count(fragment("DISTINCT ?", t.tip_id))
223227
) || 0
@@ -229,7 +233,9 @@ defmodule AlgoraWeb.HomeLive do
229233
subtotal =
230234
Repo.one(
231235
from t in Transaction,
232-
where: t.type == :credit and t.status == :succeeded,
236+
where: t.type == :credit,
237+
where: t.status == :succeeded,
238+
where: not is_nil(t.linked_transaction_id),
233239
select: count(fragment("DISTINCT ?", t.user_id))
234240
) || 0
235241

@@ -241,7 +247,9 @@ defmodule AlgoraWeb.HomeLive do
241247
from u in User,
242248
join: t in Transaction,
243249
on: t.user_id == u.id,
244-
where: t.type == :credit and t.status == :succeeded,
250+
where: t.type == :credit,
251+
where: t.status == :succeeded,
252+
where: not is_nil(t.linked_transaction_id),
245253
where: not is_nil(u.country) and u.country != "",
246254
select: count(fragment("DISTINCT ?", u.country))
247255
) || 0

0 commit comments

Comments
 (0)