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(Type.class() | :all, User.t()) :: [ShotRecord.t()]
|
||||||
@spec list_shot_records(search :: nil | String.t(), Type.class() | :all, User.t()) ::
|
@spec list_shot_records(search :: nil | String.t(), Type.class() | :all, User.t()) ::
|
||||||
[ShotRecord.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,
|
from(sg in ShotRecord,
|
||||||
as: :sg,
|
as: :sg,
|
||||||
left_join: p in Pack,
|
left_join: p in Pack,
|
||||||
|
@ -32,7 +32,7 @@ defmodule Cannery.Ammo do
|
|||||||
[Type.t()]
|
[Type.t()]
|
||||||
def list_types(search \\ nil, user, type)
|
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,
|
from(at in Type,
|
||||||
as: :at,
|
as: :at,
|
||||||
where: at.user_id == ^user_id,
|
where: at.user_id == ^user_id,
|
||||||
@ -754,7 +754,7 @@ defmodule Cannery.Ammo do
|
|||||||
User.t(),
|
User.t(),
|
||||||
show_used :: boolean()
|
show_used :: boolean()
|
||||||
) :: [Pack.t()]
|
) :: [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,
|
from(p in Pack,
|
||||||
as: :p,
|
as: :p,
|
||||||
join: at in assoc(p, :type),
|
join: at in assoc(p, :type),
|
||||||
|
Loading…
Reference in New Issue
Block a user