Skip to content

Commit 44d4217

Browse files
committed
fix: bounties query filtering for open status
1 parent 0ce60a4 commit 44d4217

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/algora/bounties/bounties.ex

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,16 @@ defmodule Algora.Bounties do
954954
from([b, r: r] in query, where: b.owner_id == ^owner_id or r.user_id == ^owner_id)
955955

956956
{:status, status}, query ->
957-
from([b] in query, where: b.status == ^status)
957+
query = where(query, [b], b.status == ^status)
958+
959+
case status do
960+
:open ->
961+
# TODO: persist state as separate field
962+
where(query, [t: t], fragment("(?->>'state' != 'closed')", t.provider_meta))
963+
964+
_ ->
965+
query
966+
end
958967

959968
{:tech_stack, tech_stack}, query ->
960969
from([b, o: o] in query,
@@ -984,8 +993,6 @@ defmodule Algora.Bounties do
984993
|> join(:left, [r: r], ro in assoc(r, :user), as: :ro)
985994
|> where([b], not is_nil(b.amount))
986995
|> where([b], b.status != :cancelled)
987-
# TODO: persist state as separate field
988-
|> where([t: t], fragment("(?->>'state' != 'closed')", t.provider_meta))
989996
|> apply_criteria(criteria)
990997
|> order_by([b], desc: b.inserted_at, desc: b.id)
991998
|> select([b, o: o, t: t, ro: ro, r: r], %{

0 commit comments

Comments
 (0)