Skip to content

Commit ec1d19e

Browse files
committed
add ats events
1 parent f566386 commit ec1d19e

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

lib/algora/cloud.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ defmodule Algora.Cloud do
8585
end
8686
end
8787

88+
def ats_event_ids do
89+
if :code.which(AlgoraCloud) == :non_existing do
90+
[]
91+
else
92+
apply(AlgoraCloud, :ats_event_ids, [])
93+
end
94+
end
95+
96+
def label_ats_event(event) do
97+
call(AlgoraCloud, :label_ats_event, [event])
98+
end
99+
88100
defp call(module, function, args) do
89101
if :code.which(module) == :non_existing do
90102
# TODO: call algora API

lib/algora/matches/matches.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ defmodule Algora.Matches do
2525
|> Repo.all()
2626
end
2727

28+
def list_job_matches_with_assocs do
29+
JobMatch
30+
|> where([jm], not is_nil(jm.provider_application_id))
31+
|> preload([:user, job_posting: :user])
32+
|> order_by([jm], desc: jm.inserted_at)
33+
|> limit(500)
34+
|> Repo.all()
35+
end
36+
2837
def get_job_match!(id) do
2938
JobMatch
3039
|> preload([:user, :job_posting])

lib/algora/matches/schemas/job_match.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,16 @@ defmodule Algora.Matches.JobMatch do
7272
|> unique_constraint([:user_id, :job_posting_id])
7373
|> generate_id()
7474
end
75+
76+
def get_application_history(match) do
77+
get_in(match.provider_application_meta, ["applicationHistory"]) || []
78+
end
79+
80+
def get_application_feedback(match) do
81+
get_in(match.provider_feedback_meta, ["feedbacks"]) || []
82+
end
83+
84+
def get_interview_schedules(match) do
85+
get_in(match.provider_interviews_meta, ["schedules"]) || []
86+
end
7587
end

lib/algora_web/live/home_live.ex

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ defmodule AlgoraWeb.HomeLive do
88
alias Algora.Accounts
99
alias Algora.Bounties
1010
alias Algora.Jobs
11+
alias Algora.Matches
12+
alias Algora.Matches.JobMatch
1113
alias Algora.Payments
1214
alias AlgoraWeb.Components.Footer
1315
alias AlgoraWeb.Components.Header
@@ -966,6 +968,70 @@ defmodule AlgoraWeb.HomeLive do
966968
"""
967969
end
968970

971+
defp event_item(%{type: :ats} = assigns) do
972+
assigns = assign(assigns, :match, assigns.event.item.match)
973+
assigns = assign(assigns, :data, assigns.event.item.event)
974+
975+
~H"""
976+
<div>
977+
<div class="relative -ml-[2.75rem]">
978+
<span
979+
:if={!@last?}
980+
class="absolute left-1 top-6 h-full w-0.5 block ml-[2.75rem] bg-muted-foreground/25"
981+
aria-hidden="true"
982+
>
983+
</span>
984+
<.link
985+
rel="noopener"
986+
target="_blank"
987+
class="w-full group inline-flex"
988+
href={"/#{@match.job_posting.user.handle}/home"}
989+
>
990+
<div class="w-full relative flex space-x-3">
991+
<div class="w-full flex min-w-0 flex-1 justify-between space-x-4 pt-1.5">
992+
<div class="w-full flex items-center gap-3">
993+
<div class="flex -space-x-1 ring-8 ring-black">
994+
<span class="relative shrink-0 overflow-hidden flex h-9 w-9 sm:h-12 sm:w-12 items-center justify-center rounded-xl ring-4 bg-gray-950 ring-black">
995+
<img
996+
class="aspect-square h-full w-full"
997+
alt={@match.job_posting.user.name}
998+
src={@match.job_posting.user.avatar_url}
999+
/>
1000+
</span>
1001+
<span class="relative shrink-0 overflow-hidden flex h-9 w-9 sm:h-12 sm:w-12 items-center justify-center rounded-xl ring-4 bg-gray-950 ring-black">
1002+
<img
1003+
class="aspect-square h-full w-full"
1004+
alt={@match.user.name}
1005+
src={@match.user.avatar_url}
1006+
/>
1007+
</span>
1008+
</div>
1009+
1010+
<div class="w-full z-10 flex gap-3 items-start xl:items-end">
1011+
<p class="text-xs transition-colors text-muted-foreground group-hover:text-foreground/90 sm:text-xl text-left">
1012+
<span class="font-semibold text-foreground/80 group-hover:text-foreground transition-colors">
1013+
{@match.job_posting.user.name}
1014+
</span>
1015+
{Algora.Cloud.label_ats_event(@data["title"]) || " <> "}
1016+
<span class="font-semibold text-foreground/80 group-hover:text-foreground transition-colors">
1017+
{@match.user.name}
1018+
</span>
1019+
</p>
1020+
<div class="ml-auto xl:ml-0 xl:mb-[2px] whitespace-nowrap text-xs text-muted-foreground sm:text-sm">
1021+
<time datetime={@event.timestamp}>
1022+
{Algora.Util.time_ago(@event.timestamp)}
1023+
</time>
1024+
</div>
1025+
</div>
1026+
</div>
1027+
</div>
1028+
</div>
1029+
</.link>
1030+
</div>
1031+
</div>
1032+
"""
1033+
end
1034+
9691035
def event_card(assigns) do
9701036
~H"""
9711037
<.link
@@ -1154,6 +1220,17 @@ defmodule AlgoraWeb.HomeLive do
11541220
transactions = Payments.list_featured_transactions()
11551221
bounties = Bounties.list_bounties(status: :open, limit: 10, amount_gt: Money.new(:USD, 200))
11561222
jobs_by_user = []
1223+
matches = Matches.list_job_matches_with_assocs()
1224+
1225+
ats_events =
1226+
Enum.flat_map(matches, fn match ->
1227+
match
1228+
|> JobMatch.get_application_history()
1229+
|> Enum.filter(fn event -> event["id"] in Algora.Cloud.ats_event_ids() end)
1230+
|> Enum.map(fn event ->
1231+
%{item: %{match: match, event: event}, type: :ats, timestamp: Algora.Util.to_date!(event["enteredStageAt"])}
1232+
end)
1233+
end)
11571234

11581235
events =
11591236
transactions
@@ -1168,6 +1245,7 @@ defmodule AlgoraWeb.HomeLive do
11681245
%{item: bounty, type: :bounty, timestamp: bounty.inserted_at}
11691246
end)
11701247
)
1248+
|> Enum.concat(ats_events)
11711249
|> Enum.sort_by(& &1.timestamp, {:desc, DateTime})
11721250

11731251
assign(socket, :events, events)

0 commit comments

Comments
 (0)