Skip to content

Commit 877f7b3

Browse files
committed
add interview count queries
1 parent 9475171 commit 877f7b3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/algora/interviews/interviews.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,18 @@ defmodule Algora.Interviews do
129129
def change_job_interview(%JobInterview{} = job_interview, attrs \\ %{}) do
130130
JobInterview.changeset(job_interview, attrs)
131131
end
132+
133+
@doc """
134+
Counts total interviews for given organization IDs.
135+
"""
136+
def count_interviews_for_orgs(org_ids) when is_list(org_ids) do
137+
Repo.aggregate(from(ji in JobInterview, where: ji.org_id in ^org_ids and ji.status != :initial), :count, :id)
138+
end
139+
140+
@doc """
141+
Counts total hires (passed interviews) for given organization IDs.
142+
"""
143+
def count_hires_for_orgs(org_ids) when is_list(org_ids) do
144+
Repo.aggregate(from(ji in JobInterview, where: ji.org_id in ^org_ids and ji.status == :passed), :count, :id)
145+
end
132146
end

0 commit comments

Comments
 (0)