Skip to content

Commit 096b728

Browse files
committed
Create helper method
1 parent 4ab3ea9 commit 096b728

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/cadet/accounts/teams.ex

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,24 @@ defmodule Cadet.Accounts.Teams do
324324

325325
length(submission) > 0
326326
end
327+
328+
@doc """
329+
Get the first member of a team.
330+
331+
## Parameters
332+
333+
* `team_id` - The team id of the team to get the first member from.
334+
335+
## Returns
336+
337+
Returns the first member of the team.
338+
339+
"""
340+
341+
def get_first_member(team_id) do
342+
TeamMember
343+
|> where([tm], tm.team_id == ^team_id)
344+
|> limit(1)
345+
|> Repo.one()
346+
end
327347
end

0 commit comments

Comments
 (0)