Skip to content

Commit c5bb1aa

Browse files
committed
feat: show bounties of featured orgs on homepage
1 parent 11413c8 commit c5bb1aa

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lib/algora/bounties/bounties.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ defmodule Algora.Bounties do
3131
| {:limit, non_neg_integer() | :infinity}
3232
| {:ticket_id, String.t()}
3333
| {:owner_id, String.t()}
34+
| {:owner_handles, [String.t()]}
3435
| {:status, :open | :paid}
3536
| {:tech_stack, [String.t()]}
3637
| {:before, %{inserted_at: DateTime.t(), id: String.t()}}
@@ -1192,6 +1193,9 @@ defmodule Algora.Bounties do
11921193
{:owner_handle, owner_handle}, query ->
11931194
from([b, o: o, ro: ro] in query, where: o.handle == ^owner_handle or ro.handle == ^owner_handle)
11941195

1196+
{:owner_handles, owner_handles}, query ->
1197+
from([b, o: o, ro: ro] in query, where: o.handle in ^owner_handles or ro.handle in ^owner_handles)
1198+
11951199
{:status, status}, query ->
11961200
query = where(query, [b], b.status == ^status)
11971201

lib/algora/settings/settings.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ defmodule Algora.Settings do
5353
set("featured_developers", %{"handles" => handles})
5454
end
5555

56+
def get_featured_orgs do
57+
case get("featured_orgs") do
58+
%{"handles" => handles} when is_list(handles) -> handles
59+
_ -> []
60+
end
61+
end
62+
63+
def set_featured_orgs(handles) when is_list(handles) do
64+
set("featured_orgs", %{"handles" => handles})
65+
end
66+
5667
def get_featured_collabs do
5768
case get("featured_collabs") do
5869
%{"handles" => handles} when is_list(handles) -> handles

lib/algora_web/live/home_live.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,21 @@ defmodule AlgoraWeb.HomeLive do
4141

4242
jobs_by_user = Enum.group_by(Jobs.list_jobs(), & &1.user)
4343

44-
bounties =
44+
bounties0 =
45+
Bounties.list_bounties(
46+
status: :open,
47+
owner_handles: Algora.Settings.get_featured_orgs()
48+
)
49+
50+
bounties1 =
4551
Bounties.list_bounties(
4652
status: :open,
4753
limit: 3,
4854
amount_gt: Money.new(:USD, 500)
4955
)
5056

57+
bounties = bounties0 ++ bounties1
58+
5159
case socket.assigns[:current_user] do
5260
%{handle: handle} = user when is_binary(handle) ->
5361
{:ok, redirect(socket, to: AlgoraWeb.UserAuth.signed_in_path(user))}

0 commit comments

Comments
 (0)