improve Ammo.get_packs_count
This commit is contained in:
@ -27,10 +27,10 @@
|
||||
<%= @container.location %>
|
||||
</span>
|
||||
|
||||
<%= if @container |> Ammo.get_packs_count_for_container!(@current_user) != 0 do %>
|
||||
<%= if Ammo.get_packs_count(@current_user, container_id: @container.id) != 0 do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Packs:") %>
|
||||
<%= @container |> Ammo.get_packs_count_for_container!(@current_user) %>
|
||||
<%= Ammo.get_packs_count(@current_user, container_id: @container.id) %>
|
||||
</span>
|
||||
|
||||
<span class="rounded-lg title text-lg">
|
||||
|
@ -52,7 +52,7 @@ defmodule CanneryWeb.ExportController do
|
||||
containers =
|
||||
Containers.list_containers(current_user)
|
||||
|> Enum.map(fn container ->
|
||||
pack_count = container |> Ammo.get_packs_count_for_container!(current_user)
|
||||
pack_count = Ammo.get_packs_count(current_user, container_id: container.id)
|
||||
round_count = container |> Ammo.get_round_count_for_container!(current_user)
|
||||
|
||||
container
|
||||
|
@ -122,8 +122,8 @@ defmodule CanneryWeb.ContainerLive.Show do
|
||||
socket
|
||||
|> assign(
|
||||
container: container,
|
||||
round_count: Ammo.get_round_count_for_container!(container, current_user),
|
||||
packs_count: Ammo.get_packs_count_for_container!(container, current_user),
|
||||
round_count: container |> Ammo.get_round_count_for_container!(current_user),
|
||||
packs_count: Ammo.get_packs_count(current_user, container_id: container.id),
|
||||
packs: packs,
|
||||
original_counts: original_counts,
|
||||
cprs: cprs,
|
||||
|
@ -148,7 +148,7 @@ defmodule CanneryWeb.PackLive.Index do
|
||||
) do
|
||||
# get total number of packs to determine whether to display onboarding
|
||||
# prompts
|
||||
packs_count = Ammo.get_packs_count!(current_user, true)
|
||||
packs_count = Ammo.get_packs_count(current_user, show_used: true)
|
||||
packs = Ammo.list_packs(current_user, search: search, class: class, show_used: show_used)
|
||||
types_count = Ammo.get_types_count!(current_user)
|
||||
containers_count = Containers.get_containers_count!(current_user)
|
||||
|
@ -66,8 +66,8 @@ defmodule CanneryWeb.TypeLive.Show do
|
||||
if show_used do
|
||||
[
|
||||
packs |> Ammo.get_original_counts(current_user),
|
||||
type |> Ammo.get_used_packs_count_for_type(current_user),
|
||||
type |> Ammo.get_packs_count_for_type(current_user, true),
|
||||
Ammo.get_packs_count(current_user, type_id: type.id, show_used: :only_used),
|
||||
Ammo.get_packs_count(current_user, type_id: type.id, show_used: true),
|
||||
type |> ActivityLog.get_used_count_for_type(current_user),
|
||||
type |> Ammo.get_historical_count_for_type(current_user)
|
||||
]
|
||||
@ -99,7 +99,7 @@ defmodule CanneryWeb.TypeLive.Show do
|
||||
original_counts: original_counts,
|
||||
used_rounds: used_rounds,
|
||||
historical_round_count: historical_round_count,
|
||||
packs_count: type |> Ammo.get_packs_count_for_type(current_user),
|
||||
packs_count: Ammo.get_packs_count(current_user, type_id: type.id),
|
||||
used_packs_count: used_packs_count,
|
||||
historical_packs_count: historical_packs_count,
|
||||
fields_to_display: fields_to_display(type),
|
||||
|
Reference in New Issue
Block a user