Skip to content

Commit 0ce60a4

Browse files
committed
fix: refine bounties query filtering and ordering
1 parent 13086e6 commit 0ce60a4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/algora/bounties/bounties.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,10 @@ defmodule Algora.Bounties do
984984
|> join(:left, [r: r], ro in assoc(r, :user), as: :ro)
985985
|> where([b], not is_nil(b.amount))
986986
|> where([b], b.status != :cancelled)
987+
# TODO: persist state as separate field
988+
|> where([t: t], fragment("(?->>'state' != 'closed')", t.provider_meta))
987989
|> apply_criteria(criteria)
988-
|> order_by([b], desc: b.amount, desc: b.inserted_at, desc: b.id)
990+
|> order_by([b], desc: b.inserted_at, desc: b.id)
989991
|> select([b, o: o, t: t, ro: ro, r: r], %{
990992
id: b.id,
991993
inserted_at: b.inserted_at,
@@ -1055,6 +1057,8 @@ defmodule Algora.Bounties do
10551057
left_join: r in assoc(t, :repository),
10561058
where: b.owner_id == ^org_id or r.user_id == ^org_id,
10571059
where: b.status == :open,
1060+
where: b.status != :cancelled,
1061+
where: not is_nil(b.amount),
10581062
# TODO: persist state as separate field
10591063
where: fragment("(?->>'state' != 'closed')", t.provider_meta)
10601064

0 commit comments

Comments
 (0)