pattern match on user struct in more cases
This commit is contained in:
parent
8a58d53dc1
commit
49628cb9bb
@ -26,7 +26,7 @@ defmodule Cannery.ActivityLog do
|
||||
@spec list_shot_records(Type.class() | :all, User.t()) :: [ShotRecord.t()]
|
||||
@spec list_shot_records(search :: nil | String.t(), Type.class() | :all, User.t()) ::
|
||||
[ShotRecord.t()]
|
||||
def list_shot_records(search \\ nil, type, %{id: user_id}) do
|
||||
def list_shot_records(search \\ nil, type, %User{id: user_id}) do
|
||||
from(sg in ShotRecord,
|
||||
as: :sg,
|
||||
left_join: p in Pack,
|
||||
|
@ -32,7 +32,7 @@ defmodule Cannery.Ammo do
|
||||
[Type.t()]
|
||||
def list_types(search \\ nil, user, type)
|
||||
|
||||
def list_types(search, %{id: user_id}, type) do
|
||||
def list_types(search, %User{id: user_id}, type) do
|
||||
from(at in Type,
|
||||
as: :at,
|
||||
where: at.user_id == ^user_id,
|
||||
@ -754,7 +754,7 @@ defmodule Cannery.Ammo do
|
||||
User.t(),
|
||||
show_used :: boolean()
|
||||
) :: [Pack.t()]
|
||||
def list_packs(search, class, %{id: user_id}, show_used \\ false) do
|
||||
def list_packs(search, class, %User{id: user_id}, show_used \\ false) do
|
||||
from(p in Pack,
|
||||
as: :p,
|
||||
join: at in assoc(p, :type),
|
||||
|
Loading…
Reference in New Issue
Block a user