@@ -4,8 +4,11 @@ defmodule AlgoraWeb.SwiftBountiesLive do
44
55 import AlgoraWeb.Components.Bounties
66 import AlgoraWeb.Components.Footer
7+ import Ecto.Query
78
89 alias Algora.Bounties
10+ alias Algora.Repo
11+ alias AlgoraWeb.Components.Logos
912
1013 def mount ( _params , _session , socket ) do
1114 if connected? ( socket ) do
@@ -21,6 +24,7 @@ defmodule AlgoraWeb.SwiftBountiesLive do
2124 |> assign ( :page_description , "Help grow the Swift ecosystem by funding the work we all depend on." )
2225 |> assign ( :page_image , "#{ AlgoraWeb.Endpoint . url ( ) } /images/og/swift.png" )
2326 |> assign_tickets ( )
27+ |> assign_active_repos ( )
2428 end
2529
2630 { :ok , socket }
@@ -104,7 +108,7 @@ defmodule AlgoraWeb.SwiftBountiesLive do
104108 </ . link >
105109 </ div >
106110 </ div >
107- < div class = "mx-auto mt-16 flex max-w-2xl sm:mt-24 lg:mt-0 lg:mr-0 lg:ml-10 lg:max-w-none xl:ml-24 " >
111+ < div class = "mx-auto mt-16 flex max-w-2xl sm:mt-24 lg:mt-0 lg:mr-0 lg:ml-10 lg:max-w-none xl:ml-24 2xl:ml-32 " >
108112 < div class = "max-w-3xl sm:max-w-5xl sm:flex-none lg:max-w-none " >
109113 < . card class = "-mx-3 bg-card/25 sm:mx-0 " id = "how-it-works " >
110114 < . card_header class = "-mx-3 sm:mx-0 " >
@@ -415,6 +419,45 @@ defmodule AlgoraWeb.SwiftBountiesLive do
415419 <% end %>
416420 </ div >
417421
422+ < div class = "mx-auto max-w-7xl py-24 sm:px-6 sm:py-32 lg:px-8 " >
423+ < div class = "relative isolate overflow-hidden px-6 text-center shadow-2xl sm:rounded-3xl sm:px-16 " >
424+ < div class = "flex items-center justify-center gap-4 " >
425+ < code class = "inline-block rounded bg-orange-950/75 px-1 py-0.5 font-mono text-sm text-orange-400 ring-1 ring-orange-400/25 " >
426+ /bounty $1000
427+ </ code >
428+ < code class = "inline-block rounded bg-orange-950/75 px-1 py-0.5 font-mono text-sm text-orange-400 ring-1 ring-orange-400/25 " >
429+ /tip $500 @username
430+ </ code >
431+ </ div >
432+ < h2 class = "mt-6 text-balance font-display text-4xl font-semibold tracking-tight text-white sm:text-5xl " >
433+ Get Started Now
434+ </ h2 >
435+ < p class = "mx-auto mt-6 max-w-xl font-medium text-lg/8 text-gray-300 " >
436+ You can create bounties and send tips on any of the Swift repositories below once you've connected your GitHub account.
437+ </ p >
438+ < div class = "mt-6 flex items-center justify-center gap-x-6 " >
439+ < . link
440+ href = { Algora.Github . authorize_url ( ) }
441+ rel = "noopener "
442+ class = "inline-flex h-12 items-center justify-center whitespace-nowrap rounded-md border border-white/80 bg-white px-6 text-lg font-semibold text-gray-900 shadow transition-colors hover:border-white hover:bg-white/90 focus-visible:outline-white-600 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 phx-submit-loading:opacity-75 "
443+ >
444+ < Logos . github class = "-ml-1 mr-2 h-6 w-6 sm:h-8 sm:w-8 " /> Connect with GitHub
445+ </ . link >
446+ </ div >
447+ < div class = "mt-10 grid grid-cols-3 gap-4 " >
448+ <%= for repo <- @ repos do %>
449+ < . link href = { repo . url } >
450+ < img
451+ src = { repo . og_image_url }
452+ alt = { repo . name }
453+ class = "rounded-lg aspect-[1200/630] w-full h-full bg-muted "
454+ />
455+ </ . link >
456+ <% end %>
457+ </ div >
458+ </ div >
459+ </ div >
460+
418461 < div class = "relative " >
419462 < . footer />
420463 </ div >
@@ -435,4 +478,45 @@ defmodule AlgoraWeb.SwiftBountiesLive do
435478
436479 assign ( socket , :tickets , tickets )
437480 end
481+
482+ defp assign_active_repos ( socket ) do
483+ active_pollers =
484+ Enum . reduce ( Algora.Github.Poller.Supervisor . which_children ( ) , [ ] , fn { _ , pid , _ , _ } , acc ->
485+ { owner , name } = GenServer . call ( pid , :get_repo_info )
486+
487+ case Algora.Github.Poller.Supervisor . find_child ( owner , name ) do
488+ { _ , pid , _ , _ } ->
489+ if GenServer . call ( pid , :is_paused ) do
490+ acc
491+ else
492+ [ { owner , name } | acc ]
493+ end
494+
495+ _ ->
496+ acc
497+ end
498+ end )
499+
500+ # Build dynamic OR conditions for each owner/name pair
501+ conditions =
502+ Enum . reduce ( active_pollers , false , fn { owner , name } , acc_query ->
503+ if acc_query do
504+ dynamic ( [ r , u ] , ^ acc_query or ( u . provider_login == ^ owner and r . name == ^ name ) )
505+ else
506+ dynamic ( [ r , u ] , u . provider_login == ^ owner and r . name == ^ name )
507+ end
508+ end )
509+
510+ repos =
511+ Repo . all (
512+ from ( r in Algora.Workspace.Repository ,
513+ join: u in assoc ( r , :user ) ,
514+ where: r . provider == "github" ,
515+ where: ^ conditions ,
516+ preload: [ user: u ]
517+ )
518+ )
519+
520+ assign ( socket , :repos , repos )
521+ end
438522end
0 commit comments