forked from shibao/cannery
		
	shot groups to shot records
This commit is contained in:
		
							
								
								
									
										10
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -57,7 +57,7 @@ | |||||||
| # v0.8.0 | # v0.8.0 | ||||||
| - Add search to catalog, ammo, container, tag and range index pages | - Add search to catalog, ammo, container, tag and range index pages | ||||||
| - Tweak urls for catalog, ammo, containers, tags and shot records | - Tweak urls for catalog, ammo, containers, tags and shot records | ||||||
| - Fix bug with shot group chart not drawing lines between days correctly | - Fix bug with shot record chart not drawing lines between days correctly | ||||||
| - Improve cards across app (make them line up with each other) | - Improve cards across app (make them line up with each other) | ||||||
| - Update translations and add spanish!!! (thank you Brea and Hannah!) | - Update translations and add spanish!!! (thank you Brea and Hannah!) | ||||||
|  |  | ||||||
| @@ -69,7 +69,7 @@ | |||||||
| - Fix toggle button styling | - Fix toggle button styling | ||||||
| - Miscellanous code improvements | - Miscellanous code improvements | ||||||
| - Improve container index table | - Improve container index table | ||||||
| - Fix bug with ammo not updating after deleting shot group | - Fix bug with ammo not updating after deleting shot record | ||||||
| - Replace ammo "added on" with "purchased on" | - Replace ammo "added on" with "purchased on" | ||||||
| - Miscellaneous wording improvements | - Miscellaneous wording improvements | ||||||
| - Update translations | - Update translations | ||||||
| @@ -103,7 +103,7 @@ | |||||||
| - Add ammo type cloning | - Add ammo type cloning | ||||||
| - Add container cloning | - Add container cloning | ||||||
| - Fix bug with moving ammo packs between containers | - Fix bug with moving ammo packs between containers | ||||||
| - Add button to set rounds left to 0 when creating a shot group | - Add button to set rounds left to 0 when creating a shot record | ||||||
| - Update project dependencies | - Update project dependencies | ||||||
|  |  | ||||||
| # v0.5.4 | # v0.5.4 | ||||||
| @@ -155,8 +155,8 @@ | |||||||
| # v0.3.0 | # v0.3.0 | ||||||
| - Fix ammo type counts not showing when count is 0 | - Fix ammo type counts not showing when count is 0 | ||||||
| - Add prompt to create first container before first ammo group | - Add prompt to create first container before first ammo group | ||||||
| - Edit and delete shot groups from ammo group show page | - Edit and delete shot records from ammo group show page | ||||||
| - Use today's date when adding new shot groups | - Use today's date when adding new shot records | ||||||
| - Create multiple ammo groups at one time | - Create multiple ammo groups at one time | ||||||
|  |  | ||||||
| # v0.2.3 | # v0.2.3 | ||||||
|   | |||||||
| @@ -5,29 +5,29 @@ defmodule Cannery.ActivityLog do | |||||||
|  |  | ||||||
|   import Ecto.Query, warn: false |   import Ecto.Query, warn: false | ||||||
|   alias Cannery.Ammo.{AmmoType, Pack} |   alias Cannery.Ammo.{AmmoType, Pack} | ||||||
|   alias Cannery.{Accounts.User, ActivityLog.ShotGroup, Repo} |   alias Cannery.{Accounts.User, ActivityLog.ShotRecord, Repo} | ||||||
|   alias Ecto.{Multi, Queryable} |   alias Ecto.{Multi, Queryable} | ||||||
|  |  | ||||||
|   @doc """ |   @doc """ | ||||||
|   Returns the list of shot_groups. |   Returns the list of shot_records. | ||||||
|  |  | ||||||
|   ## Examples |   ## Examples | ||||||
|  |  | ||||||
|       iex> list_shot_groups(:all, %User{id: 123}) |       iex> list_shot_records(:all, %User{id: 123}) | ||||||
|       [%ShotGroup{}, ...] |       [%ShotRecord{}, ...] | ||||||
|  |  | ||||||
|       iex> list_shot_groups("cool", :all, %User{id: 123}) |       iex> list_shot_records("cool", :all, %User{id: 123}) | ||||||
|       [%ShotGroup{notes: "My cool shot group"}, ...] |       [%ShotRecord{notes: "My cool shot record"}, ...] | ||||||
|  |  | ||||||
|       iex> list_shot_groups("cool", :rifle, %User{id: 123}) |       iex> list_shot_records("cool", :rifle, %User{id: 123}) | ||||||
|       [%ShotGroup{notes: "Shot some rifle rounds"}, ...] |       [%ShotRecord{notes: "Shot some rifle rounds"}, ...] | ||||||
|  |  | ||||||
|   """ |   """ | ||||||
|   @spec list_shot_groups(AmmoType.class() | :all, User.t()) :: [ShotGroup.t()] |   @spec list_shot_records(AmmoType.class() | :all, User.t()) :: [ShotRecord.t()] | ||||||
|   @spec list_shot_groups(search :: nil | String.t(), AmmoType.class() | :all, User.t()) :: |   @spec list_shot_records(search :: nil | String.t(), AmmoType.class() | :all, User.t()) :: | ||||||
|           [ShotGroup.t()] |           [ShotRecord.t()] | ||||||
|   def list_shot_groups(search \\ nil, type, %{id: user_id}) do |   def list_shot_records(search \\ nil, type, %{id: user_id}) do | ||||||
|     from(sg in ShotGroup, |     from(sg in ShotRecord, | ||||||
|       as: :sg, |       as: :sg, | ||||||
|       left_join: ag in Pack, |       left_join: ag in Pack, | ||||||
|       as: :ag, |       as: :ag, | ||||||
| @@ -38,16 +38,16 @@ defmodule Cannery.ActivityLog do | |||||||
|       where: sg.user_id == ^user_id, |       where: sg.user_id == ^user_id, | ||||||
|       distinct: sg.id |       distinct: sg.id | ||||||
|     ) |     ) | ||||||
|     |> list_shot_groups_search(search) |     |> list_shot_records_search(search) | ||||||
|     |> list_shot_groups_filter_type(type) |     |> list_shot_records_filter_type(type) | ||||||
|     |> Repo.all() |     |> Repo.all() | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @spec list_shot_groups_search(Queryable.t(), search :: String.t() | nil) :: |   @spec list_shot_records_search(Queryable.t(), search :: String.t() | nil) :: | ||||||
|           Queryable.t() |           Queryable.t() | ||||||
|   defp list_shot_groups_search(query, search) when search in ["", nil], do: query |   defp list_shot_records_search(query, search) when search in ["", nil], do: query | ||||||
|  |  | ||||||
|   defp list_shot_groups_search(query, search) when search |> is_binary() do |   defp list_shot_records_search(query, search) when search |> is_binary() do | ||||||
|     trimmed_search = String.trim(search) |     trimmed_search = String.trim(search) | ||||||
|  |  | ||||||
|     query |     query | ||||||
| @@ -79,18 +79,18 @@ defmodule Cannery.ActivityLog do | |||||||
|     }) |     }) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @spec list_shot_groups_filter_type(Queryable.t(), AmmoType.class() | :all) :: |   @spec list_shot_records_filter_type(Queryable.t(), AmmoType.class() | :all) :: | ||||||
|           Queryable.t() |           Queryable.t() | ||||||
|   defp list_shot_groups_filter_type(query, :rifle), |   defp list_shot_records_filter_type(query, :rifle), | ||||||
|     do: query |> where([at: at], at.class == :rifle) |     do: query |> where([at: at], at.class == :rifle) | ||||||
|  |  | ||||||
|   defp list_shot_groups_filter_type(query, :pistol), |   defp list_shot_records_filter_type(query, :pistol), | ||||||
|     do: query |> where([at: at], at.class == :pistol) |     do: query |> where([at: at], at.class == :pistol) | ||||||
|  |  | ||||||
|   defp list_shot_groups_filter_type(query, :shotgun), |   defp list_shot_records_filter_type(query, :shotgun), | ||||||
|     do: query |> where([at: at], at.class == :shotgun) |     do: query |> where([at: at], at.class == :shotgun) | ||||||
|  |  | ||||||
|   defp list_shot_groups_filter_type(query, _all), do: query |   defp list_shot_records_filter_type(query, _all), do: query | ||||||
|  |  | ||||||
|   @doc """ |   @doc """ | ||||||
|   Returns a count of shot records. |   Returns a count of shot records. | ||||||
| @@ -104,43 +104,43 @@ defmodule Cannery.ActivityLog do | |||||||
|   @spec get_shot_record_count!(User.t()) :: integer() |   @spec get_shot_record_count!(User.t()) :: integer() | ||||||
|   def get_shot_record_count!(%User{id: user_id}) do |   def get_shot_record_count!(%User{id: user_id}) do | ||||||
|     Repo.one( |     Repo.one( | ||||||
|       from sg in ShotGroup, |       from sg in ShotRecord, | ||||||
|         where: sg.user_id == ^user_id, |         where: sg.user_id == ^user_id, | ||||||
|         select: count(sg.id), |         select: count(sg.id), | ||||||
|         distinct: true |         distinct: true | ||||||
|     ) || 0 |     ) || 0 | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @spec list_shot_groups_for_pack(Pack.t(), User.t()) :: [ShotGroup.t()] |   @spec list_shot_records_for_pack(Pack.t(), User.t()) :: [ShotRecord.t()] | ||||||
|   def list_shot_groups_for_pack( |   def list_shot_records_for_pack( | ||||||
|         %Pack{id: pack_id, user_id: user_id}, |         %Pack{id: pack_id, user_id: user_id}, | ||||||
|         %User{id: user_id} |         %User{id: user_id} | ||||||
|       ) do |       ) do | ||||||
|     Repo.all( |     Repo.all( | ||||||
|       from sg in ShotGroup, |       from sg in ShotRecord, | ||||||
|         where: sg.pack_id == ^pack_id, |         where: sg.pack_id == ^pack_id, | ||||||
|         where: sg.user_id == ^user_id |         where: sg.user_id == ^user_id | ||||||
|     ) |     ) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @doc """ |   @doc """ | ||||||
|   Gets a single shot_group. |   Gets a single shot_record. | ||||||
|  |  | ||||||
|   Raises `Ecto.NoResultsError` if the Shot group does not exist. |   Raises `Ecto.NoResultsError` if the shot record does not exist. | ||||||
|  |  | ||||||
|   ## Examples |   ## Examples | ||||||
|  |  | ||||||
|       iex> get_shot_group!(123, %User{id: 123}) |       iex> get_shot_record!(123, %User{id: 123}) | ||||||
|       %ShotGroup{} |       %ShotRecord{} | ||||||
|  |  | ||||||
|       iex> get_shot_group!(456, %User{id: 123}) |       iex> get_shot_record!(456, %User{id: 123}) | ||||||
|       ** (Ecto.NoResultsError) |       ** (Ecto.NoResultsError) | ||||||
|  |  | ||||||
|   """ |   """ | ||||||
|   @spec get_shot_group!(ShotGroup.id(), User.t()) :: ShotGroup.t() |   @spec get_shot_record!(ShotRecord.id(), User.t()) :: ShotRecord.t() | ||||||
|   def get_shot_group!(id, %User{id: user_id}) do |   def get_shot_record!(id, %User{id: user_id}) do | ||||||
|     Repo.one!( |     Repo.one!( | ||||||
|       from sg in ShotGroup, |       from sg in ShotRecord, | ||||||
|         where: sg.id == ^id, |         where: sg.id == ^id, | ||||||
|         where: sg.user_id == ^user_id, |         where: sg.user_id == ^user_id, | ||||||
|         order_by: sg.date |         order_by: sg.date | ||||||
| @@ -148,28 +148,28 @@ defmodule Cannery.ActivityLog do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   @doc """ |   @doc """ | ||||||
|   Creates a shot_group. |   Creates a shot_record. | ||||||
|  |  | ||||||
|   ## Examples |   ## Examples | ||||||
|  |  | ||||||
|       iex> create_shot_group(%{field: value}, %User{id: 123}) |       iex> create_shot_record(%{field: value}, %User{id: 123}) | ||||||
|       {:ok, %ShotGroup{}} |       {:ok, %ShotRecord{}} | ||||||
|  |  | ||||||
|       iex> create_shot_group(%{field: bad_value}, %User{id: 123}) |       iex> create_shot_record(%{field: bad_value}, %User{id: 123}) | ||||||
|       {:error, %Ecto.Changeset{}} |       {:error, %Ecto.Changeset{}} | ||||||
|  |  | ||||||
|   """ |   """ | ||||||
|   @spec create_shot_group(attrs :: map(), User.t(), Pack.t()) :: |   @spec create_shot_record(attrs :: map(), User.t(), Pack.t()) :: | ||||||
|           {:ok, ShotGroup.t()} | {:error, ShotGroup.changeset() | nil} |           {:ok, ShotRecord.t()} | {:error, ShotRecord.changeset() | nil} | ||||||
|   def create_shot_group(attrs, user, pack) do |   def create_shot_record(attrs, user, pack) do | ||||||
|     Multi.new() |     Multi.new() | ||||||
|     |> Multi.insert( |     |> Multi.insert( | ||||||
|       :create_shot_group, |       :create_shot_record, | ||||||
|       %ShotGroup{} |> ShotGroup.create_changeset(user, pack, attrs) |       %ShotRecord{} |> ShotRecord.create_changeset(user, pack, attrs) | ||||||
|     ) |     ) | ||||||
|     |> Multi.run( |     |> Multi.run( | ||||||
|       :pack, |       :pack, | ||||||
|       fn _repo, %{create_shot_group: %{pack_id: pack_id, user_id: user_id}} -> |       fn _repo, %{create_shot_record: %{pack_id: pack_id, user_id: user_id}} -> | ||||||
|         pack = |         pack = | ||||||
|           Repo.one( |           Repo.one( | ||||||
|             from ag in Pack, |             from ag in Pack, | ||||||
| @@ -182,52 +182,52 @@ defmodule Cannery.ActivityLog do | |||||||
|     ) |     ) | ||||||
|     |> Multi.update( |     |> Multi.update( | ||||||
|       :update_pack, |       :update_pack, | ||||||
|       fn %{create_shot_group: %{count: shot_group_count}, pack: %{count: pack_count}} -> |       fn %{create_shot_record: %{count: shot_record_count}, pack: %{count: pack_count}} -> | ||||||
|         pack |> Pack.range_changeset(%{"count" => pack_count - shot_group_count}) |         pack |> Pack.range_changeset(%{"count" => pack_count - shot_record_count}) | ||||||
|       end |       end | ||||||
|     ) |     ) | ||||||
|     |> Repo.transaction() |     |> Repo.transaction() | ||||||
|     |> case do |     |> case do | ||||||
|       {:ok, %{create_shot_group: shot_group}} -> {:ok, shot_group} |       {:ok, %{create_shot_record: shot_record}} -> {:ok, shot_record} | ||||||
|       {:error, :create_shot_group, changeset, _changes_so_far} -> {:error, changeset} |       {:error, :create_shot_record, changeset, _changes_so_far} -> {:error, changeset} | ||||||
|       {:error, _other_transaction, _value, _changes_so_far} -> {:error, nil} |       {:error, _other_transaction, _value, _changes_so_far} -> {:error, nil} | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @doc """ |   @doc """ | ||||||
|   Updates a shot_group. |   Updates a shot_record. | ||||||
|  |  | ||||||
|   ## Examples |   ## Examples | ||||||
|  |  | ||||||
|       iex> update_shot_group(shot_group, %{field: new_value}, %User{id: 123}) |       iex> update_shot_record(shot_record, %{field: new_value}, %User{id: 123}) | ||||||
|       {:ok, %ShotGroup{}} |       {:ok, %ShotRecord{}} | ||||||
|  |  | ||||||
|       iex> update_shot_group(shot_group, %{field: bad_value}, %User{id: 123}) |       iex> update_shot_record(shot_record, %{field: bad_value}, %User{id: 123}) | ||||||
|       {:error, %Ecto.Changeset{}} |       {:error, %Ecto.Changeset{}} | ||||||
|  |  | ||||||
|   """ |   """ | ||||||
|   @spec update_shot_group(ShotGroup.t(), attrs :: map(), User.t()) :: |   @spec update_shot_record(ShotRecord.t(), attrs :: map(), User.t()) :: | ||||||
|           {:ok, ShotGroup.t()} | {:error, ShotGroup.changeset() | nil} |           {:ok, ShotRecord.t()} | {:error, ShotRecord.changeset() | nil} | ||||||
|   def update_shot_group( |   def update_shot_record( | ||||||
|         %ShotGroup{count: count, user_id: user_id} = shot_group, |         %ShotRecord{count: count, user_id: user_id} = shot_record, | ||||||
|         attrs, |         attrs, | ||||||
|         %User{id: user_id} = user |         %User{id: user_id} = user | ||||||
|       ) do |       ) do | ||||||
|     Multi.new() |     Multi.new() | ||||||
|     |> Multi.update( |     |> Multi.update( | ||||||
|       :update_shot_group, |       :update_shot_record, | ||||||
|       shot_group |> ShotGroup.update_changeset(user, attrs) |       shot_record |> ShotRecord.update_changeset(user, attrs) | ||||||
|     ) |     ) | ||||||
|     |> Multi.run( |     |> Multi.run( | ||||||
|       :pack, |       :pack, | ||||||
|       fn repo, %{update_shot_group: %{pack_id: pack_id, user_id: user_id}} -> |       fn repo, %{update_shot_record: %{pack_id: pack_id, user_id: user_id}} -> | ||||||
|         {:ok, repo.one(from ag in Pack, where: ag.id == ^pack_id and ag.user_id == ^user_id)} |         {:ok, repo.one(from ag in Pack, where: ag.id == ^pack_id and ag.user_id == ^user_id)} | ||||||
|       end |       end | ||||||
|     ) |     ) | ||||||
|     |> Multi.update( |     |> Multi.update( | ||||||
|       :update_pack, |       :update_pack, | ||||||
|       fn %{ |       fn %{ | ||||||
|            update_shot_group: %{count: new_count}, |            update_shot_record: %{count: new_count}, | ||||||
|            pack: %{count: pack_count} = pack |            pack: %{count: pack_count} = pack | ||||||
|          } -> |          } -> | ||||||
|         shot_diff_to_add = new_count - count |         shot_diff_to_add = new_count - count | ||||||
| @@ -237,42 +237,42 @@ defmodule Cannery.ActivityLog do | |||||||
|     ) |     ) | ||||||
|     |> Repo.transaction() |     |> Repo.transaction() | ||||||
|     |> case do |     |> case do | ||||||
|       {:ok, %{update_shot_group: shot_group}} -> {:ok, shot_group} |       {:ok, %{update_shot_record: shot_record}} -> {:ok, shot_record} | ||||||
|       {:error, :update_shot_group, changeset, _changes_so_far} -> {:error, changeset} |       {:error, :update_shot_record, changeset, _changes_so_far} -> {:error, changeset} | ||||||
|       {:error, _other_transaction, _value, _changes_so_far} -> {:error, nil} |       {:error, _other_transaction, _value, _changes_so_far} -> {:error, nil} | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @doc """ |   @doc """ | ||||||
|   Deletes a shot_group. |   Deletes a shot_record. | ||||||
|  |  | ||||||
|   ## Examples |   ## Examples | ||||||
|  |  | ||||||
|       iex> delete_shot_group(shot_group, %User{id: 123}) |       iex> delete_shot_record(shot_record, %User{id: 123}) | ||||||
|       {:ok, %ShotGroup{}} |       {:ok, %ShotRecord{}} | ||||||
|  |  | ||||||
|       iex> delete_shot_group(shot_group, %User{id: 123}) |       iex> delete_shot_record(shot_record, %User{id: 123}) | ||||||
|       {:error, %Ecto.Changeset{}} |       {:error, %Ecto.Changeset{}} | ||||||
|  |  | ||||||
|   """ |   """ | ||||||
|   @spec delete_shot_group(ShotGroup.t(), User.t()) :: |   @spec delete_shot_record(ShotRecord.t(), User.t()) :: | ||||||
|           {:ok, ShotGroup.t()} | {:error, ShotGroup.changeset()} |           {:ok, ShotRecord.t()} | {:error, ShotRecord.changeset()} | ||||||
|   def delete_shot_group( |   def delete_shot_record( | ||||||
|         %ShotGroup{user_id: user_id} = shot_group, |         %ShotRecord{user_id: user_id} = shot_record, | ||||||
|         %User{id: user_id} |         %User{id: user_id} | ||||||
|       ) do |       ) do | ||||||
|     Multi.new() |     Multi.new() | ||||||
|     |> Multi.delete(:delete_shot_group, shot_group) |     |> Multi.delete(:delete_shot_record, shot_record) | ||||||
|     |> Multi.run( |     |> Multi.run( | ||||||
|       :pack, |       :pack, | ||||||
|       fn repo, %{delete_shot_group: %{pack_id: pack_id, user_id: user_id}} -> |       fn repo, %{delete_shot_record: %{pack_id: pack_id, user_id: user_id}} -> | ||||||
|         {:ok, repo.one(from ag in Pack, where: ag.id == ^pack_id and ag.user_id == ^user_id)} |         {:ok, repo.one(from ag in Pack, where: ag.id == ^pack_id and ag.user_id == ^user_id)} | ||||||
|       end |       end | ||||||
|     ) |     ) | ||||||
|     |> Multi.update( |     |> Multi.update( | ||||||
|       :update_pack, |       :update_pack, | ||||||
|       fn %{ |       fn %{ | ||||||
|            delete_shot_group: %{count: count}, |            delete_shot_record: %{count: count}, | ||||||
|            pack: %{count: pack_count} = pack |            pack: %{count: pack_count} = pack | ||||||
|          } -> |          } -> | ||||||
|         new_pack_count = pack_count + count |         new_pack_count = pack_count + count | ||||||
| @@ -281,8 +281,8 @@ defmodule Cannery.ActivityLog do | |||||||
|     ) |     ) | ||||||
|     |> Repo.transaction() |     |> Repo.transaction() | ||||||
|     |> case do |     |> case do | ||||||
|       {:ok, %{delete_shot_group: shot_group}} -> {:ok, shot_group} |       {:ok, %{delete_shot_record: shot_record}} -> {:ok, shot_record} | ||||||
|       {:error, :delete_shot_group, changeset, _changes_so_far} -> {:error, changeset} |       {:error, :delete_shot_record, changeset, _changes_so_far} -> {:error, changeset} | ||||||
|       {:error, _other_transaction, _value, _changes_so_far} -> {:error, nil} |       {:error, _other_transaction, _value, _changes_so_far} -> {:error, nil} | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @@ -308,7 +308,7 @@ defmodule Cannery.ActivityLog do | |||||||
|       |> Enum.map(fn %{id: pack_id} -> pack_id end) |       |> Enum.map(fn %{id: pack_id} -> pack_id end) | ||||||
|  |  | ||||||
|     Repo.all( |     Repo.all( | ||||||
|       from sg in ShotGroup, |       from sg in ShotRecord, | ||||||
|         where: sg.pack_id in ^pack_ids, |         where: sg.pack_id in ^pack_ids, | ||||||
|         where: sg.user_id == ^user_id, |         where: sg.user_id == ^user_id, | ||||||
|         group_by: sg.pack_id, |         group_by: sg.pack_id, | ||||||
| @@ -318,7 +318,7 @@ defmodule Cannery.ActivityLog do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   @doc """ |   @doc """ | ||||||
|   Returns the last entered shot group date for a pack |   Returns the last entered shot record date for a pack | ||||||
|   """ |   """ | ||||||
|   @spec get_last_used_date(Pack.t(), User.t()) :: Date.t() | nil |   @spec get_last_used_date(Pack.t(), User.t()) :: Date.t() | nil | ||||||
|   def get_last_used_date(%Pack{id: pack_id} = pack, user) do |   def get_last_used_date(%Pack{id: pack_id} = pack, user) do | ||||||
| @@ -328,7 +328,7 @@ defmodule Cannery.ActivityLog do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   @doc """ |   @doc """ | ||||||
|   Returns the last entered shot group date for a pack |   Returns the last entered shot record date for a pack | ||||||
|   """ |   """ | ||||||
|   @spec get_last_used_dates([Pack.t()], User.t()) :: %{optional(Pack.id()) => Date.t()} |   @spec get_last_used_dates([Pack.t()], User.t()) :: %{optional(Pack.id()) => Date.t()} | ||||||
|   def get_last_used_dates(packs, %User{id: user_id}) do |   def get_last_used_dates(packs, %User{id: user_id}) do | ||||||
| @@ -337,7 +337,7 @@ defmodule Cannery.ActivityLog do | |||||||
|       |> Enum.map(fn %Pack{id: pack_id, user_id: ^user_id} -> pack_id end) |       |> Enum.map(fn %Pack{id: pack_id, user_id: ^user_id} -> pack_id end) | ||||||
|  |  | ||||||
|     Repo.all( |     Repo.all( | ||||||
|       from sg in ShotGroup, |       from sg in ShotRecord, | ||||||
|         where: sg.pack_id in ^pack_ids, |         where: sg.pack_id in ^pack_ids, | ||||||
|         where: sg.user_id == ^user_id, |         where: sg.user_id == ^user_id, | ||||||
|         group_by: sg.pack_id, |         group_by: sg.pack_id, | ||||||
| @@ -385,7 +385,7 @@ defmodule Cannery.ActivityLog do | |||||||
|  |  | ||||||
|     Repo.all( |     Repo.all( | ||||||
|       from ag in Pack, |       from ag in Pack, | ||||||
|         left_join: sg in ShotGroup, |         left_join: sg in ShotRecord, | ||||||
|         on: ag.id == sg.pack_id, |         on: ag.id == sg.pack_id, | ||||||
|         where: ag.ammo_type_id in ^ammo_type_ids, |         where: ag.ammo_type_id in ^ammo_type_ids, | ||||||
|         where: not (sg.count |> is_nil()), |         where: not (sg.count |> is_nil()), | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| defmodule Cannery.ActivityLog.ShotGroup do | defmodule Cannery.ActivityLog.ShotRecord do | ||||||
|   @moduledoc """ |   @moduledoc """ | ||||||
|   A shot group records a group of ammo shot during a range trip |   A shot record records a group of ammo shot during a range trip | ||||||
|   """ |   """ | ||||||
|  |  | ||||||
|   use Ecto.Schema |   use Ecto.Schema | ||||||
| @@ -19,7 +19,7 @@ defmodule Cannery.ActivityLog.ShotGroup do | |||||||
|            ]} |            ]} | ||||||
|   @primary_key {:id, :binary_id, autogenerate: true} |   @primary_key {:id, :binary_id, autogenerate: true} | ||||||
|   @foreign_key_type :binary_id |   @foreign_key_type :binary_id | ||||||
|   schema "shot_groups" do |   schema "shot_records" do | ||||||
|     field :count, :integer |     field :count, :integer | ||||||
|     field :date, :date |     field :date, :date | ||||||
|     field :notes, :string |     field :notes, :string | ||||||
| @@ -40,41 +40,41 @@ defmodule Cannery.ActivityLog.ShotGroup do | |||||||
|           inserted_at: NaiveDateTime.t(), |           inserted_at: NaiveDateTime.t(), | ||||||
|           updated_at: NaiveDateTime.t() |           updated_at: NaiveDateTime.t() | ||||||
|         } |         } | ||||||
|   @type new_shot_group :: %__MODULE__{} |   @type new_shot_record :: %__MODULE__{} | ||||||
|   @type id :: UUID.t() |   @type id :: UUID.t() | ||||||
|   @type changeset :: Changeset.t(t() | new_shot_group()) |   @type changeset :: Changeset.t(t() | new_shot_record()) | ||||||
|  |  | ||||||
|   @doc false |   @doc false | ||||||
|   @spec create_changeset( |   @spec create_changeset( | ||||||
|           new_shot_group(), |           new_shot_record(), | ||||||
|           User.t() | any(), |           User.t() | any(), | ||||||
|           Pack.t() | any(), |           Pack.t() | any(), | ||||||
|           attrs :: map() |           attrs :: map() | ||||||
|         ) :: changeset() |         ) :: changeset() | ||||||
|   def create_changeset( |   def create_changeset( | ||||||
|         shot_group, |         shot_record, | ||||||
|         %User{id: user_id}, |         %User{id: user_id}, | ||||||
|         %Pack{id: pack_id, user_id: user_id} = pack, |         %Pack{id: pack_id, user_id: user_id} = pack, | ||||||
|         attrs |         attrs | ||||||
|       ) do |       ) do | ||||||
|     shot_group |     shot_record | ||||||
|     |> change(user_id: user_id) |     |> change(user_id: user_id) | ||||||
|     |> change(pack_id: pack_id) |     |> change(pack_id: pack_id) | ||||||
|     |> cast(attrs, [:count, :notes, :date]) |     |> cast(attrs, [:count, :notes, :date]) | ||||||
|     |> validate_length(:notes, max: 255) |     |> validate_length(:notes, max: 255) | ||||||
|     |> validate_create_shot_group_count(pack) |     |> validate_create_shot_record_count(pack) | ||||||
|     |> validate_required([:date, :pack_id, :user_id]) |     |> validate_required([:date, :pack_id, :user_id]) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def create_changeset(shot_group, _invalid_user, _invalid_pack, attrs) do |   def create_changeset(shot_record, _invalid_user, _invalid_pack, attrs) do | ||||||
|     shot_group |     shot_record | ||||||
|     |> cast(attrs, [:count, :notes, :date]) |     |> cast(attrs, [:count, :notes, :date]) | ||||||
|     |> validate_length(:notes, max: 255) |     |> validate_length(:notes, max: 255) | ||||||
|     |> validate_required([:pack_id, :user_id]) |     |> validate_required([:pack_id, :user_id]) | ||||||
|     |> add_error(:invalid, dgettext("errors", "Please select a valid user and ammo pack")) |     |> add_error(:invalid, dgettext("errors", "Please select a valid user and ammo pack")) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp validate_create_shot_group_count(changeset, %Pack{count: pack_count}) do |   defp validate_create_shot_record_count(changeset, %Pack{count: pack_count}) do | ||||||
|     case changeset |> Changeset.get_field(:count) do |     case changeset |> Changeset.get_field(:count) do | ||||||
|       nil -> |       nil -> | ||||||
|         changeset |> Changeset.add_error(:ammo_left, dgettext("errors", "can't be blank")) |         changeset |> Changeset.add_error(:ammo_left, dgettext("errors", "can't be blank")) | ||||||
| @@ -95,25 +95,25 @@ defmodule Cannery.ActivityLog.ShotGroup do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   @doc false |   @doc false | ||||||
|   @spec update_changeset(t() | new_shot_group(), User.t(), attrs :: map()) :: changeset() |   @spec update_changeset(t() | new_shot_record(), User.t(), attrs :: map()) :: changeset() | ||||||
|   def update_changeset(%__MODULE__{} = shot_group, user, attrs) do |   def update_changeset(%__MODULE__{} = shot_record, user, attrs) do | ||||||
|     shot_group |     shot_record | ||||||
|     |> cast(attrs, [:count, :notes, :date]) |     |> cast(attrs, [:count, :notes, :date]) | ||||||
|     |> validate_length(:notes, max: 255) |     |> validate_length(:notes, max: 255) | ||||||
|     |> validate_number(:count, greater_than: 0) |     |> validate_number(:count, greater_than: 0) | ||||||
|     |> validate_required([:count, :date]) |     |> validate_required([:count, :date]) | ||||||
|     |> validate_update_shot_group_count(shot_group, user) |     |> validate_update_shot_record_count(shot_record, user) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp validate_update_shot_group_count( |   defp validate_update_shot_record_count( | ||||||
|          changeset, |          changeset, | ||||||
|          %__MODULE__{pack_id: pack_id, count: count}, |          %__MODULE__{pack_id: pack_id, count: count}, | ||||||
|          user |          user | ||||||
|        ) do |        ) do | ||||||
|     %{count: pack_count} = Ammo.get_pack!(pack_id, user) |     %{count: pack_count} = Ammo.get_pack!(pack_id, user) | ||||||
|  |  | ||||||
|     new_shot_group_count = changeset |> Changeset.get_field(:count) |     new_shot_record_count = changeset |> Changeset.get_field(:count) | ||||||
|     shot_diff_to_add = new_shot_group_count - count |     shot_diff_to_add = new_shot_record_count - count | ||||||
|  |  | ||||||
|     if shot_diff_to_add > pack_count do |     if shot_diff_to_add > pack_count do | ||||||
|       error = dgettext("errors", "Count can be at most %{count} shots", count: pack_count + count) |       error = dgettext("errors", "Count can be at most %{count} shots", count: pack_count + count) | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ defmodule Cannery.Ammo do | |||||||
|   import Ecto.Query, warn: false |   import Ecto.Query, warn: false | ||||||
|   alias Cannery.{Accounts.User, Containers, Repo} |   alias Cannery.{Accounts.User, Containers, Repo} | ||||||
|   alias Cannery.Containers.{Container, ContainerTag, Tag} |   alias Cannery.Containers.{Container, ContainerTag, Tag} | ||||||
|   alias Cannery.{ActivityLog, ActivityLog.ShotGroup} |   alias Cannery.{ActivityLog, ActivityLog.ShotRecord} | ||||||
|   alias Cannery.Ammo.{AmmoType, Pack} |   alias Cannery.Ammo.{AmmoType, Pack} | ||||||
|   alias Ecto.{Changeset, Queryable} |   alias Ecto.{Changeset, Queryable} | ||||||
|  |  | ||||||
| @@ -167,7 +167,7 @@ defmodule Cannery.Ammo do | |||||||
|       |> Enum.map(fn %AmmoType{id: ammo_type_id, user_id: ^user_id} -> ammo_type_id end) |       |> Enum.map(fn %AmmoType{id: ammo_type_id, user_id: ^user_id} -> ammo_type_id end) | ||||||
|  |  | ||||||
|     sg_total_query = |     sg_total_query = | ||||||
|       from sg in ShotGroup, |       from sg in ShotRecord, | ||||||
|         where: not (sg.count |> is_nil()), |         where: not (sg.count |> is_nil()), | ||||||
|         group_by: sg.pack_id, |         group_by: sg.pack_id, | ||||||
|         select: %{pack_id: sg.pack_id, total: sum(sg.count)} |         select: %{pack_id: sg.pack_id, total: sum(sg.count)} | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| defmodule CanneryWeb.Components.AddShotGroupComponent do | defmodule CanneryWeb.Components.AddShotRecordComponent do | ||||||
|   @moduledoc """ |   @moduledoc """ | ||||||
|   Livecomponent that can create a ShotGroup |   Livecomponent that can create a ShotRecord | ||||||
|   """ |   """ | ||||||
|  |  | ||||||
|   use CanneryWeb, :live_component |   use CanneryWeb, :live_component | ||||||
|   alias Cannery.{Accounts.User, ActivityLog, ActivityLog.ShotGroup, Ammo.Pack} |   alias Cannery.{Accounts.User, ActivityLog, ActivityLog.ShotRecord, Ammo.Pack} | ||||||
|   alias Ecto.Changeset |   alias Ecto.Changeset | ||||||
|   alias Phoenix.LiveView.{JS, Socket} |   alias Phoenix.LiveView.{JS, Socket} | ||||||
|  |  | ||||||
| @@ -19,8 +19,8 @@ defmodule CanneryWeb.Components.AddShotGroupComponent do | |||||||
|         ) :: {:ok, Socket.t()} |         ) :: {:ok, Socket.t()} | ||||||
|   def update(%{pack: pack, current_user: current_user} = assigns, socket) do |   def update(%{pack: pack, current_user: current_user} = assigns, socket) do | ||||||
|     changeset = |     changeset = | ||||||
|       %ShotGroup{date: Date.utc_today()} |       %ShotRecord{date: Date.utc_today()} | ||||||
|       |> ShotGroup.create_changeset(current_user, pack, %{}) |       |> ShotRecord.create_changeset(current_user, pack, %{}) | ||||||
|  |  | ||||||
|     {:ok, socket |> assign(assigns) |> assign(:changeset, changeset)} |     {:ok, socket |> assign(assigns) |> assign(:changeset, changeset)} | ||||||
|   end |   end | ||||||
| @@ -28,12 +28,12 @@ defmodule CanneryWeb.Components.AddShotGroupComponent do | |||||||
|   @impl true |   @impl true | ||||||
|   def handle_event( |   def handle_event( | ||||||
|         "validate", |         "validate", | ||||||
|         %{"shot_group" => shot_group_params}, |         %{"shot_record" => shot_record_params}, | ||||||
|         %{assigns: %{pack: pack, current_user: current_user}} = socket |         %{assigns: %{pack: pack, current_user: current_user}} = socket | ||||||
|       ) do |       ) do | ||||||
|     params = shot_group_params |> process_params(pack) |     params = shot_record_params |> process_params(pack) | ||||||
|  |  | ||||||
|     changeset = %ShotGroup{} |> ShotGroup.create_changeset(current_user, pack, params) |     changeset = %ShotRecord{} |> ShotRecord.create_changeset(current_user, pack, params) | ||||||
|  |  | ||||||
|     changeset = |     changeset = | ||||||
|       case changeset |> Changeset.apply_action(:validate) do |       case changeset |> Changeset.apply_action(:validate) do | ||||||
| @@ -46,17 +46,17 @@ defmodule CanneryWeb.Components.AddShotGroupComponent do | |||||||
|  |  | ||||||
|   def handle_event( |   def handle_event( | ||||||
|         "save", |         "save", | ||||||
|         %{"shot_group" => shot_group_params}, |         %{"shot_record" => shot_record_params}, | ||||||
|         %{ |         %{ | ||||||
|           assigns: %{pack: pack, current_user: current_user, return_to: return_to} |           assigns: %{pack: pack, current_user: current_user, return_to: return_to} | ||||||
|         } = socket |         } = socket | ||||||
|       ) do |       ) do | ||||||
|     socket = |     socket = | ||||||
|       shot_group_params |       shot_record_params | ||||||
|       |> process_params(pack) |       |> process_params(pack) | ||||||
|       |> ActivityLog.create_shot_group(current_user, pack) |       |> ActivityLog.create_shot_record(current_user, pack) | ||||||
|       |> case do |       |> case do | ||||||
|         {:ok, _shot_group} -> |         {:ok, _shot_record} -> | ||||||
|           prompt = dgettext("prompts", "Shots recorded successfully") |           prompt = dgettext("prompts", "Shots recorded successfully") | ||||||
|           socket |> put_flash(:info, prompt) |> push_navigate(to: return_to) |           socket |> put_flash(:info, prompt) |> push_navigate(to: return_to) | ||||||
|  |  | ||||||
| @@ -69,7 +69,7 @@ defmodule CanneryWeb.Components.AddShotGroupComponent do | |||||||
|  |  | ||||||
|   # calculate count from shots left |   # calculate count from shots left | ||||||
|   defp process_params(params, %Pack{count: count}) do |   defp process_params(params, %Pack{count: count}) do | ||||||
|     shot_group_count = |     shot_record_count = | ||||||
|       if params |> Map.get("ammo_left", "") == "" do |       if params |> Map.get("ammo_left", "") == "" do | ||||||
|         nil |         nil | ||||||
|       else |       else | ||||||
| @@ -77,6 +77,6 @@ defmodule CanneryWeb.Components.AddShotGroupComponent do | |||||||
|         count - new_count |         count - new_count | ||||||
|       end |       end | ||||||
|  |  | ||||||
|     params |> Map.put("count", shot_group_count) |     params |> Map.put("count", shot_record_count) | ||||||
|   end |   end | ||||||
| end | end | ||||||
|   | |||||||
| @@ -1,9 +1,9 @@ | |||||||
| defmodule CanneryWeb.Components.ShotGroupTableComponent do | defmodule CanneryWeb.Components.ShotRecordTableComponent do | ||||||
|   @moduledoc """ |   @moduledoc """ | ||||||
|   A component that displays a list of shot groups |   A component that displays a list of shot records | ||||||
|   """ |   """ | ||||||
|   use CanneryWeb, :live_component |   use CanneryWeb, :live_component | ||||||
|   alias Cannery.{Accounts.User, ActivityLog.ShotGroup, Ammo, ComparableDate} |   alias Cannery.{Accounts.User, ActivityLog.ShotRecord, Ammo, ComparableDate} | ||||||
|   alias Ecto.UUID |   alias Ecto.UUID | ||||||
|   alias Phoenix.LiveView.{Rendered, Socket} |   alias Phoenix.LiveView.{Rendered, Socket} | ||||||
|  |  | ||||||
| @@ -12,26 +12,29 @@ defmodule CanneryWeb.Components.ShotGroupTableComponent do | |||||||
|           %{ |           %{ | ||||||
|             required(:id) => UUID.t(), |             required(:id) => UUID.t(), | ||||||
|             required(:current_user) => User.t(), |             required(:current_user) => User.t(), | ||||||
|             optional(:shot_groups) => [ShotGroup.t()], |             optional(:shot_records) => [ShotRecord.t()], | ||||||
|             optional(:actions) => Rendered.t(), |             optional(:actions) => Rendered.t(), | ||||||
|             optional(any()) => any() |             optional(any()) => any() | ||||||
|           }, |           }, | ||||||
|           Socket.t() |           Socket.t() | ||||||
|         ) :: {:ok, Socket.t()} |         ) :: {:ok, Socket.t()} | ||||||
|   def update(%{id: _id, shot_groups: _shot_groups, current_user: _current_user} = assigns, socket) do |   def update( | ||||||
|  |         %{id: _id, shot_records: _shot_records, current_user: _current_user} = assigns, | ||||||
|  |         socket | ||||||
|  |       ) do | ||||||
|     socket = |     socket = | ||||||
|       socket |       socket | ||||||
|       |> assign(assigns) |       |> assign(assigns) | ||||||
|       |> assign_new(:actions, fn -> [] end) |       |> assign_new(:actions, fn -> [] end) | ||||||
|       |> display_shot_groups() |       |> display_shot_records() | ||||||
|  |  | ||||||
|     {:ok, socket} |     {:ok, socket} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp display_shot_groups( |   defp display_shot_records( | ||||||
|          %{ |          %{ | ||||||
|            assigns: %{ |            assigns: %{ | ||||||
|              shot_groups: shot_groups, |              shot_records: shot_records, | ||||||
|              current_user: current_user, |              current_user: current_user, | ||||||
|              actions: actions |              actions: actions | ||||||
|            } |            } | ||||||
| @@ -46,16 +49,16 @@ defmodule CanneryWeb.Components.ShotGroupTableComponent do | |||||||
|     ] |     ] | ||||||
|  |  | ||||||
|     packs = |     packs = | ||||||
|       shot_groups |       shot_records | ||||||
|       |> Enum.map(fn %{pack_id: pack_id} -> pack_id end) |       |> Enum.map(fn %{pack_id: pack_id} -> pack_id end) | ||||||
|       |> Ammo.get_packs(current_user) |       |> Ammo.get_packs(current_user) | ||||||
|  |  | ||||||
|     extra_data = %{current_user: current_user, actions: actions, packs: packs} |     extra_data = %{current_user: current_user, actions: actions, packs: packs} | ||||||
|  |  | ||||||
|     rows = |     rows = | ||||||
|       shot_groups |       shot_records | ||||||
|       |> Enum.map(fn shot_group -> |       |> Enum.map(fn shot_record -> | ||||||
|         shot_group |> get_row_data_for_shot_group(columns, extra_data) |         shot_record |> get_row_data_for_shot_record(columns, extra_data) | ||||||
|       end) |       end) | ||||||
|  |  | ||||||
|     socket |     socket | ||||||
| @@ -81,12 +84,12 @@ defmodule CanneryWeb.Components.ShotGroupTableComponent do | |||||||
|     """ |     """ | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @spec get_row_data_for_shot_group(ShotGroup.t(), columns :: [map()], extra_data :: map()) :: |   @spec get_row_data_for_shot_record(ShotRecord.t(), columns :: [map()], extra_data :: map()) :: | ||||||
|           map() |           map() | ||||||
|   defp get_row_data_for_shot_group(shot_group, columns, extra_data) do |   defp get_row_data_for_shot_record(shot_record, columns, extra_data) do | ||||||
|     columns |     columns | ||||||
|     |> Map.new(fn %{key: key} -> |     |> Map.new(fn %{key: key} -> | ||||||
|       {key, get_row_value(key, shot_group, extra_data)} |       {key, get_row_value(key, shot_record, extra_data)} | ||||||
|     end) |     end) | ||||||
|   end |   end | ||||||
|  |  | ||||||
| @@ -108,13 +111,13 @@ defmodule CanneryWeb.Components.ShotGroupTableComponent do | |||||||
|      """} |      """} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_row_value(:actions, shot_group, %{actions: actions}) do |   defp get_row_value(:actions, shot_record, %{actions: actions}) do | ||||||
|     assigns = %{actions: actions, shot_group: shot_group} |     assigns = %{actions: actions, shot_record: shot_record} | ||||||
|  |  | ||||||
|     ~H""" |     ~H""" | ||||||
|     <%= render_slot(@actions, @shot_group) %> |     <%= render_slot(@actions, @shot_record) %> | ||||||
|     """ |     """ | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp get_row_value(key, shot_group, _extra_data), do: shot_group |> Map.get(key) |   defp get_row_value(key, shot_record, _extra_data), do: shot_record |> Map.get(key) | ||||||
| end | end | ||||||
|   | |||||||
| @@ -47,7 +47,7 @@ defmodule CanneryWeb.ExportController do | |||||||
|         }) |         }) | ||||||
|       end) |       end) | ||||||
|  |  | ||||||
|     shot_groups = ActivityLog.list_shot_groups(:all, current_user) |     shot_records = ActivityLog.list_shot_records(:all, current_user) | ||||||
|  |  | ||||||
|     containers = |     containers = | ||||||
|       Containers.list_containers(current_user) |       Containers.list_containers(current_user) | ||||||
| @@ -68,7 +68,7 @@ defmodule CanneryWeb.ExportController do | |||||||
|       user: current_user, |       user: current_user, | ||||||
|       ammo_types: ammo_types, |       ammo_types: ammo_types, | ||||||
|       packs: packs, |       packs: packs, | ||||||
|       shot_groups: shot_groups, |       shot_records: shot_records, | ||||||
|       containers: containers |       containers: containers | ||||||
|     }) |     }) | ||||||
|   end |   end | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ defmodule CanneryWeb.PackLive.Index do | |||||||
|  |  | ||||||
|   defp apply_action( |   defp apply_action( | ||||||
|          %{assigns: %{current_user: current_user}} = socket, |          %{assigns: %{current_user: current_user}} = socket, | ||||||
|          :add_shot_group, |          :add_shot_record, | ||||||
|          %{"id" => id} |          %{"id" => id} | ||||||
|        ) do |        ) do | ||||||
|     socket |     socket | ||||||
|   | |||||||
| @@ -121,7 +121,7 @@ | |||||||
|               </button> |               </button> | ||||||
|  |  | ||||||
|               <.link |               <.link | ||||||
|                 patch={Routes.pack_index_path(Endpoint, :add_shot_group, pack)} |                 patch={Routes.pack_index_path(Endpoint, :add_shot_record, pack)} | ||||||
|                 class="mx-2 my-1 text-sm btn btn-primary" |                 class="mx-2 my-1 text-sm btn btn-primary" | ||||||
|               > |               > | ||||||
|                 <%= dgettext("actions", "Record shots") %> |                 <%= dgettext("actions", "Record shots") %> | ||||||
| @@ -213,10 +213,10 @@ | |||||||
|         current_user={@current_user} |         current_user={@current_user} | ||||||
|       /> |       /> | ||||||
|     </.modal> |     </.modal> | ||||||
|   <% :add_shot_group -> %> |   <% :add_shot_record -> %> | ||||||
|     <.modal return_to={Routes.pack_index_path(Endpoint, :index)}> |     <.modal return_to={Routes.pack_index_path(Endpoint, :index)}> | ||||||
|       <.live_component |       <.live_component | ||||||
|         module={CanneryWeb.Components.AddShotGroupComponent} |         module={CanneryWeb.Components.AddShotRecordComponent} | ||||||
|         id={:new} |         id={:new} | ||||||
|         title={@page_title} |         title={@page_title} | ||||||
|         action={@live_action} |         action={@live_action} | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|   """ |   """ | ||||||
|  |  | ||||||
|   use CanneryWeb, :live_view |   use CanneryWeb, :live_view | ||||||
|   alias Cannery.{ActivityLog, ActivityLog.ShotGroup} |   alias Cannery.{ActivityLog, ActivityLog.ShotRecord} | ||||||
|   alias Cannery.{Ammo, Ammo.Pack} |   alias Cannery.{Ammo, Ammo.Pack} | ||||||
|   alias Cannery.{ComparableDate, Containers} |   alias Cannery.{ComparableDate, Containers} | ||||||
|   alias CanneryWeb.Endpoint |   alias CanneryWeb.Endpoint | ||||||
| @@ -15,15 +15,15 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|  |  | ||||||
|   @impl true |   @impl true | ||||||
|   def handle_params( |   def handle_params( | ||||||
|         %{"id" => id, "shot_group_id" => shot_group_id}, |         %{"id" => id, "shot_record_id" => shot_record_id}, | ||||||
|         _url, |         _url, | ||||||
|         %{assigns: %{live_action: live_action, current_user: current_user}} = socket |         %{assigns: %{live_action: live_action, current_user: current_user}} = socket | ||||||
|       ) do |       ) do | ||||||
|     shot_group = ActivityLog.get_shot_group!(shot_group_id, current_user) |     shot_record = ActivityLog.get_shot_record!(shot_record_id, current_user) | ||||||
|  |  | ||||||
|     socket = |     socket = | ||||||
|       socket |       socket | ||||||
|       |> assign(page_title: page_title(live_action), shot_group: shot_group) |       |> assign(page_title: page_title(live_action), shot_record: shot_record) | ||||||
|       |> display_pack(id) |       |> display_pack(id) | ||||||
|  |  | ||||||
|     {:noreply, socket} |     {:noreply, socket} | ||||||
| @@ -38,8 +38,8 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|     {:noreply, socket} |     {:noreply, socket} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp page_title(:add_shot_group), do: gettext("Record Shots") |   defp page_title(:add_shot_record), do: gettext("Record Shots") | ||||||
|   defp page_title(:edit_shot_group), do: gettext("Edit Shot Records") |   defp page_title(:edit_shot_record), do: gettext("Edit Shot Records") | ||||||
|   defp page_title(:move), do: gettext("Move Ammo") |   defp page_title(:move), do: gettext("Move Ammo") | ||||||
|   defp page_title(:show), do: gettext("Show Ammo") |   defp page_title(:show), do: gettext("Show Ammo") | ||||||
|   defp page_title(:edit), do: gettext("Edit Ammo") |   defp page_title(:edit), do: gettext("Edit Ammo") | ||||||
| @@ -69,13 +69,13 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   def handle_event( |   def handle_event( | ||||||
|         "delete_shot_group", |         "delete_shot_record", | ||||||
|         %{"id" => id}, |         %{"id" => id}, | ||||||
|         %{assigns: %{pack: %{id: pack_id}, current_user: current_user}} = socket |         %{assigns: %{pack: %{id: pack_id}, current_user: current_user}} = socket | ||||||
|       ) do |       ) do | ||||||
|     {:ok, _} = |     {:ok, _} = | ||||||
|       ActivityLog.get_shot_group!(id, current_user) |       ActivityLog.get_shot_record!(id, current_user) | ||||||
|       |> ActivityLog.delete_shot_group(current_user) |       |> ActivityLog.delete_shot_record(current_user) | ||||||
|  |  | ||||||
|     prompt = dgettext("prompts", "Shot records deleted succesfully") |     prompt = dgettext("prompts", "Shot records deleted succesfully") | ||||||
|     {:noreply, socket |> put_flash(:info, prompt) |> display_pack(pack_id)} |     {:noreply, socket |> put_flash(:info, prompt) |> display_pack(pack_id)} | ||||||
| @@ -93,12 +93,12 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|       %{label: gettext("Actions"), key: :actions, sortable: false} |       %{label: gettext("Actions"), key: :actions, sortable: false} | ||||||
|     ] |     ] | ||||||
|  |  | ||||||
|     shot_groups = ActivityLog.list_shot_groups_for_pack(pack, current_user) |     shot_records = ActivityLog.list_shot_records_for_pack(pack, current_user) | ||||||
|  |  | ||||||
|     rows = |     rows = | ||||||
|       shot_groups |       shot_records | ||||||
|       |> Enum.map(fn shot_group -> |       |> Enum.map(fn shot_record -> | ||||||
|         pack |> get_table_row_for_shot_group(shot_group, columns) |         pack |> get_table_row_for_shot_record(shot_record, columns) | ||||||
|       end) |       end) | ||||||
|  |  | ||||||
|     socket |     socket | ||||||
| @@ -107,7 +107,7 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|       original_count: Ammo.get_original_count(pack, current_user), |       original_count: Ammo.get_original_count(pack, current_user), | ||||||
|       percentage_remaining: Ammo.get_percentage_remaining(pack, current_user), |       percentage_remaining: Ammo.get_percentage_remaining(pack, current_user), | ||||||
|       container: container_id && Containers.get_container!(container_id, current_user), |       container: container_id && Containers.get_container!(container_id, current_user), | ||||||
|       shot_groups: shot_groups, |       shot_records: shot_records, | ||||||
|       columns: columns, |       columns: columns, | ||||||
|       rows: rows |       rows: rows | ||||||
|     ) |     ) | ||||||
| @@ -119,9 +119,9 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|   @spec display_currency(float()) :: String.t() |   @spec display_currency(float()) :: String.t() | ||||||
|   defp display_currency(float), do: :erlang.float_to_binary(float, decimals: 2) |   defp display_currency(float), do: :erlang.float_to_binary(float, decimals: 2) | ||||||
|  |  | ||||||
|   @spec get_table_row_for_shot_group(Pack.t(), ShotGroup.t(), [map()]) :: map() |   @spec get_table_row_for_shot_record(Pack.t(), ShotRecord.t(), [map()]) :: map() | ||||||
|   defp get_table_row_for_shot_group(pack, %{id: id, date: date} = shot_group, columns) do |   defp get_table_row_for_shot_record(pack, %{id: id, date: date} = shot_record, columns) do | ||||||
|     assigns = %{pack: pack, shot_group: shot_group} |     assigns = %{pack: pack, shot_record: shot_record} | ||||||
|  |  | ||||||
|     columns |     columns | ||||||
|     |> Map.new(fn %{key: key} -> |     |> Map.new(fn %{key: key} -> | ||||||
| @@ -139,11 +139,11 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|             ~H""" |             ~H""" | ||||||
|             <div class="px-4 py-2 space-x-4 flex justify-center items-center"> |             <div class="px-4 py-2 space-x-4 flex justify-center items-center"> | ||||||
|               <.link |               <.link | ||||||
|                 patch={Routes.pack_show_path(Endpoint, :edit_shot_group, @pack, @shot_group)} |                 patch={Routes.pack_show_path(Endpoint, :edit_shot_record, @pack, @shot_record)} | ||||||
|                 class="text-primary-600 link" |                 class="text-primary-600 link" | ||||||
|                 aria-label={ |                 aria-label={ | ||||||
|                   dgettext("actions", "Edit shot group of %{shot_group_count} shots", |                   dgettext("actions", "Edit shot record of %{shot_record_count} shots", | ||||||
|                     shot_group_count: @shot_group.count |                     shot_record_count: @shot_record.count | ||||||
|                   ) |                   ) | ||||||
|                 } |                 } | ||||||
|               > |               > | ||||||
| @@ -153,12 +153,12 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|               <.link |               <.link | ||||||
|                 href="#" |                 href="#" | ||||||
|                 class="text-primary-600 link" |                 class="text-primary-600 link" | ||||||
|                 phx-click="delete_shot_group" |                 phx-click="delete_shot_record" | ||||||
|                 phx-value-id={@shot_group.id} |                 phx-value-id={@shot_record.id} | ||||||
|                 data-confirm={dgettext("prompts", "Are you sure you want to delete this shot record?")} |                 data-confirm={dgettext("prompts", "Are you sure you want to delete this shot record?")} | ||||||
|                 aria-label={ |                 aria-label={ | ||||||
|                   dgettext("actions", "Delete shot record of %{shot_group_count} shots", |                   dgettext("actions", "Delete shot record of %{shot_record_count} shots", | ||||||
|                     shot_group_count: @shot_group.count |                     shot_record_count: @shot_record.count | ||||||
|                   ) |                   ) | ||||||
|                 } |                 } | ||||||
|               > |               > | ||||||
| @@ -168,7 +168,7 @@ defmodule CanneryWeb.PackLive.Show do | |||||||
|             """ |             """ | ||||||
|  |  | ||||||
|           key -> |           key -> | ||||||
|             shot_group |> Map.get(key) |             shot_record |> Map.get(key) | ||||||
|         end |         end | ||||||
|  |  | ||||||
|       {key, value} |       {key, value} | ||||||
|   | |||||||
| @@ -90,7 +90,7 @@ | |||||||
|       </.link> |       </.link> | ||||||
|  |  | ||||||
|       <.link |       <.link | ||||||
|         patch={Routes.pack_show_path(Endpoint, :add_shot_group, @pack)} |         patch={Routes.pack_show_path(Endpoint, :add_shot_record, @pack)} | ||||||
|         class="mx-4 my-2 btn btn-primary" |         class="mx-4 my-2 btn btn-primary" | ||||||
|       > |       > | ||||||
|         <%= dgettext("actions", "Record shots") %> |         <%= dgettext("actions", "Record shots") %> | ||||||
| @@ -112,7 +112,7 @@ | |||||||
|     <% end %> |     <% end %> | ||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
|   <%= unless @shot_groups |> Enum.empty?() do %> |   <%= unless @shot_records |> Enum.empty?() do %> | ||||||
|     <hr class="mb-4 w-full" /> |     <hr class="mb-4 w-full" /> | ||||||
|  |  | ||||||
|     <h1 class="mb-4 px-4 py-2 text-center rounded-lg title text-xl"> |     <h1 class="mb-4 px-4 py-2 text-center rounded-lg title text-xl"> | ||||||
| @@ -121,7 +121,7 @@ | |||||||
|  |  | ||||||
|     <.live_component |     <.live_component | ||||||
|       module={CanneryWeb.Components.TableComponent} |       module={CanneryWeb.Components.TableComponent} | ||||||
|       id="pack_shot_groups_table" |       id="pack_shot_records_table" | ||||||
|       columns={@columns} |       columns={@columns} | ||||||
|       rows={@rows} |       rows={@rows} | ||||||
|     /> |     /> | ||||||
| @@ -141,22 +141,22 @@ | |||||||
|         current_user={@current_user} |         current_user={@current_user} | ||||||
|       /> |       /> | ||||||
|     </.modal> |     </.modal> | ||||||
|   <% :edit_shot_group -> %> |   <% :edit_shot_record -> %> | ||||||
|     <.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}> |     <.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}> | ||||||
|       <.live_component |       <.live_component | ||||||
|         module={CanneryWeb.RangeLive.FormComponent} |         module={CanneryWeb.RangeLive.FormComponent} | ||||||
|         id={@shot_group.id} |         id={@shot_record.id} | ||||||
|         title={@page_title} |         title={@page_title} | ||||||
|         action={@live_action} |         action={@live_action} | ||||||
|         shot_group={@shot_group} |         shot_record={@shot_record} | ||||||
|         return_to={Routes.pack_show_path(Endpoint, :show, @pack)} |         return_to={Routes.pack_show_path(Endpoint, :show, @pack)} | ||||||
|         current_user={@current_user} |         current_user={@current_user} | ||||||
|       /> |       /> | ||||||
|     </.modal> |     </.modal> | ||||||
|   <% :add_shot_group -> %> |   <% :add_shot_record -> %> | ||||||
|     <.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}> |     <.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}> | ||||||
|       <.live_component |       <.live_component | ||||||
|         module={CanneryWeb.Components.AddShotGroupComponent} |         module={CanneryWeb.Components.AddShotRecordComponent} | ||||||
|         id={:new} |         id={:new} | ||||||
|         title={@page_title} |         title={@page_title} | ||||||
|         action={@live_action} |         action={@live_action} | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| defmodule CanneryWeb.RangeLive.FormComponent do | defmodule CanneryWeb.RangeLive.FormComponent do | ||||||
|   @moduledoc """ |   @moduledoc """ | ||||||
|   Livecomponent that can update a ShotGroup |   Livecomponent that can update a ShotRecord | ||||||
|   """ |   """ | ||||||
|  |  | ||||||
|   use CanneryWeb, :live_component |   use CanneryWeb, :live_component | ||||||
|   alias Cannery.{Accounts.User, ActivityLog, ActivityLog.ShotGroup, Ammo, Ammo.Pack} |   alias Cannery.{Accounts.User, ActivityLog, ActivityLog.ShotRecord, Ammo, Ammo.Pack} | ||||||
|   alias Ecto.Changeset |   alias Ecto.Changeset | ||||||
|   alias Phoenix.LiveView.Socket |   alias Phoenix.LiveView.Socket | ||||||
|  |  | ||||||
| @@ -14,7 +14,7 @@ defmodule CanneryWeb.RangeLive.FormComponent do | |||||||
|   @impl true |   @impl true | ||||||
|   @spec update( |   @spec update( | ||||||
|           %{ |           %{ | ||||||
|             required(:shot_group) => ShotGroup.t(), |             required(:shot_record) => ShotRecord.t(), | ||||||
|             required(:current_user) => User.t(), |             required(:current_user) => User.t(), | ||||||
|             optional(:pack) => Pack.t(), |             optional(:pack) => Pack.t(), | ||||||
|             optional(any()) => any() |             optional(any()) => any() | ||||||
| @@ -23,7 +23,7 @@ defmodule CanneryWeb.RangeLive.FormComponent do | |||||||
|         ) :: {:ok, Socket.t()} |         ) :: {:ok, Socket.t()} | ||||||
|   def update( |   def update( | ||||||
|         %{ |         %{ | ||||||
|           shot_group: %ShotGroup{pack_id: pack_id}, |           shot_record: %ShotRecord{pack_id: pack_id}, | ||||||
|           current_user: current_user |           current_user: current_user | ||||||
|         } = assigns, |         } = assigns, | ||||||
|         socket |         socket | ||||||
| @@ -33,24 +33,24 @@ defmodule CanneryWeb.RangeLive.FormComponent do | |||||||
|     {:ok, socket |> assign(assigns) |> assign(:pack, pack) |> assign_changeset(%{})} |     {:ok, socket |> assign(assigns) |> assign(:pack, pack) |> assign_changeset(%{})} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def update(%{shot_group: %ShotGroup{}} = assigns, socket) do |   def update(%{shot_record: %ShotRecord{}} = assigns, socket) do | ||||||
|     {:ok, socket |> assign(assigns) |> assign_changeset(%{})} |     {:ok, socket |> assign(assigns) |> assign_changeset(%{})} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @impl true |   @impl true | ||||||
|   def handle_event("validate", %{"shot_group" => shot_group_params}, socket) do |   def handle_event("validate", %{"shot_record" => shot_record_params}, socket) do | ||||||
|     {:noreply, socket |> assign_changeset(shot_group_params, :validate)} |     {:noreply, socket |> assign_changeset(shot_record_params, :validate)} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def handle_event( |   def handle_event( | ||||||
|         "save", |         "save", | ||||||
|         %{"shot_group" => shot_group_params}, |         %{"shot_record" => shot_record_params}, | ||||||
|         %{assigns: %{shot_group: shot_group, current_user: current_user, return_to: return_to}} = |         %{assigns: %{shot_record: shot_record, current_user: current_user, return_to: return_to}} = | ||||||
|           socket |           socket | ||||||
|       ) do |       ) do | ||||||
|     socket = |     socket = | ||||||
|       case ActivityLog.update_shot_group(shot_group, shot_group_params, current_user) do |       case ActivityLog.update_shot_record(shot_record, shot_record_params, current_user) do | ||||||
|         {:ok, _shot_group} -> |         {:ok, _shot_record} -> | ||||||
|           prompt = dgettext("prompts", "Shot records updated successfully") |           prompt = dgettext("prompts", "Shot records updated successfully") | ||||||
|           socket |> put_flash(:info, prompt) |> push_navigate(to: return_to) |           socket |> put_flash(:info, prompt) |> push_navigate(to: return_to) | ||||||
|  |  | ||||||
| @@ -67,22 +67,22 @@ defmodule CanneryWeb.RangeLive.FormComponent do | |||||||
|              action: live_action, |              action: live_action, | ||||||
|              current_user: user, |              current_user: user, | ||||||
|              pack: pack, |              pack: pack, | ||||||
|              shot_group: shot_group |              shot_record: shot_record | ||||||
|            } |            } | ||||||
|          } = socket, |          } = socket, | ||||||
|          shot_group_params, |          shot_record_params, | ||||||
|          action \\ nil |          action \\ nil | ||||||
|        ) do |        ) do | ||||||
|     default_action = |     default_action = | ||||||
|       case live_action do |       case live_action do | ||||||
|         :add_shot_group -> :insert |         :add_shot_record -> :insert | ||||||
|         editing when editing in [:edit, :edit_shot_group] -> :update |         editing when editing in [:edit, :edit_shot_record] -> :update | ||||||
|       end |       end | ||||||
|  |  | ||||||
|     changeset = |     changeset = | ||||||
|       case default_action do |       case default_action do | ||||||
|         :insert -> shot_group |> ShotGroup.create_changeset(user, pack, shot_group_params) |         :insert -> shot_record |> ShotRecord.create_changeset(user, pack, shot_record_params) | ||||||
|         :update -> shot_group |> ShotGroup.update_changeset(user, shot_group_params) |         :update -> shot_record |> ShotRecord.update_changeset(user, shot_record_params) | ||||||
|       end |       end | ||||||
|  |  | ||||||
|     changeset = |     changeset = | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ | |||||||
|     <%= label(f, :count, gettext("Shots fired"), class: "title text-lg text-primary-600") %> |     <%= label(f, :count, gettext("Shots fired"), class: "title text-lg text-primary-600") %> | ||||||
|     <%= number_input(f, :count, |     <%= number_input(f, :count, | ||||||
|       min: 1, |       min: 1, | ||||||
|       max: @shot_group.count + @pack.count, |       max: @shot_record.count + @pack.count, | ||||||
|       class: "input input-primary col-span-2" |       class: "input input-primary col-span-2" | ||||||
|     ) %> |     ) %> | ||||||
|     <%= error_tag(f, :count, "col-span-3") %> |     <%= error_tag(f, :count, "col-span-3") %> | ||||||
|   | |||||||
| @@ -4,17 +4,17 @@ defmodule CanneryWeb.RangeLive.Index do | |||||||
|   """ |   """ | ||||||
|  |  | ||||||
|   use CanneryWeb, :live_view |   use CanneryWeb, :live_view | ||||||
|   alias Cannery.{ActivityLog, ActivityLog.ShotGroup, Ammo} |   alias Cannery.{ActivityLog, ActivityLog.ShotRecord, Ammo} | ||||||
|   alias CanneryWeb.Endpoint |   alias CanneryWeb.Endpoint | ||||||
|   alias Phoenix.LiveView.Socket |   alias Phoenix.LiveView.Socket | ||||||
|  |  | ||||||
|   @impl true |   @impl true | ||||||
|   def mount(%{"search" => search}, _session, socket) do |   def mount(%{"search" => search}, _session, socket) do | ||||||
|     {:ok, socket |> assign(class: :all, search: search) |> display_shot_groups()} |     {:ok, socket |> assign(class: :all, search: search) |> display_shot_records()} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def mount(_params, _session, socket) do |   def mount(_params, _session, socket) do | ||||||
|     {:ok, socket |> assign(class: :all, search: nil) |> display_shot_groups()} |     {:ok, socket |> assign(class: :all, search: nil) |> display_shot_records()} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @impl true |   @impl true | ||||||
| @@ -24,7 +24,7 @@ defmodule CanneryWeb.RangeLive.Index do | |||||||
|  |  | ||||||
|   defp apply_action( |   defp apply_action( | ||||||
|          %{assigns: %{current_user: current_user}} = socket, |          %{assigns: %{current_user: current_user}} = socket, | ||||||
|          :add_shot_group, |          :add_shot_record, | ||||||
|          %{"id" => id} |          %{"id" => id} | ||||||
|        ) do |        ) do | ||||||
|     socket |     socket | ||||||
| @@ -38,7 +38,7 @@ defmodule CanneryWeb.RangeLive.Index do | |||||||
|     socket |     socket | ||||||
|     |> assign( |     |> assign( | ||||||
|       page_title: gettext("Edit Shot Records"), |       page_title: gettext("Edit Shot Records"), | ||||||
|       shot_group: ActivityLog.get_shot_group!(id, current_user) |       shot_record: ActivityLog.get_shot_record!(id, current_user) | ||||||
|     ) |     ) | ||||||
|   end |   end | ||||||
|  |  | ||||||
| @@ -46,7 +46,7 @@ defmodule CanneryWeb.RangeLive.Index do | |||||||
|     socket |     socket | ||||||
|     |> assign( |     |> assign( | ||||||
|       page_title: gettext("New Shot Records"), |       page_title: gettext("New Shot Records"), | ||||||
|       shot_group: %ShotGroup{} |       shot_record: %ShotRecord{} | ||||||
|     ) |     ) | ||||||
|   end |   end | ||||||
|  |  | ||||||
| @@ -55,9 +55,9 @@ defmodule CanneryWeb.RangeLive.Index do | |||||||
|     |> assign( |     |> assign( | ||||||
|       page_title: gettext("Shot Records"), |       page_title: gettext("Shot Records"), | ||||||
|       search: nil, |       search: nil, | ||||||
|       shot_group: nil |       shot_record: nil | ||||||
|     ) |     ) | ||||||
|     |> display_shot_groups() |     |> display_shot_records() | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp apply_action(socket, :search, %{"search" => search}) do |   defp apply_action(socket, :search, %{"search" => search}) do | ||||||
| @@ -65,19 +65,19 @@ defmodule CanneryWeb.RangeLive.Index do | |||||||
|     |> assign( |     |> assign( | ||||||
|       page_title: gettext("Shot Records"), |       page_title: gettext("Shot Records"), | ||||||
|       search: search, |       search: search, | ||||||
|       shot_group: nil |       shot_record: nil | ||||||
|     ) |     ) | ||||||
|     |> display_shot_groups() |     |> display_shot_records() | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @impl true |   @impl true | ||||||
|   def handle_event("delete", %{"id" => id}, %{assigns: %{current_user: current_user}} = socket) do |   def handle_event("delete", %{"id" => id}, %{assigns: %{current_user: current_user}} = socket) do | ||||||
|     {:ok, _} = |     {:ok, _} = | ||||||
|       ActivityLog.get_shot_group!(id, current_user) |       ActivityLog.get_shot_record!(id, current_user) | ||||||
|       |> ActivityLog.delete_shot_group(current_user) |       |> ActivityLog.delete_shot_record(current_user) | ||||||
|  |  | ||||||
|     prompt = dgettext("prompts", "Shot records deleted succesfully") |     prompt = dgettext("prompts", "Shot records deleted succesfully") | ||||||
|     {:noreply, socket |> put_flash(:info, prompt) |> display_shot_groups()} |     {:noreply, socket |> put_flash(:info, prompt) |> display_shot_records()} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def handle_event( |   def handle_event( | ||||||
| @@ -90,7 +90,7 @@ defmodule CanneryWeb.RangeLive.Index do | |||||||
|     {:ok, _pack} = pack |> Ammo.update_pack(%{"staged" => !pack.staged}, current_user) |     {:ok, _pack} = pack |> Ammo.update_pack(%{"staged" => !pack.staged}, current_user) | ||||||
|  |  | ||||||
|     prompt = dgettext("prompts", "Ammo unstaged succesfully") |     prompt = dgettext("prompts", "Ammo unstaged succesfully") | ||||||
|     {:noreply, socket |> put_flash(:info, prompt) |> display_shot_groups()} |     {:noreply, socket |> put_flash(:info, prompt) |> display_shot_records()} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def handle_event("search", %{"search" => %{"search_term" => ""}}, socket) do |   def handle_event("search", %{"search" => %{"search_term" => ""}}, socket) do | ||||||
| @@ -102,28 +102,28 @@ defmodule CanneryWeb.RangeLive.Index do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   def handle_event("change_class", %{"ammo_type" => %{"class" => "rifle"}}, socket) do |   def handle_event("change_class", %{"ammo_type" => %{"class" => "rifle"}}, socket) do | ||||||
|     {:noreply, socket |> assign(:class, :rifle) |> display_shot_groups()} |     {:noreply, socket |> assign(:class, :rifle) |> display_shot_records()} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def handle_event("change_class", %{"ammo_type" => %{"class" => "shotgun"}}, socket) do |   def handle_event("change_class", %{"ammo_type" => %{"class" => "shotgun"}}, socket) do | ||||||
|     {:noreply, socket |> assign(:class, :shotgun) |> display_shot_groups()} |     {:noreply, socket |> assign(:class, :shotgun) |> display_shot_records()} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def handle_event("change_class", %{"ammo_type" => %{"class" => "pistol"}}, socket) do |   def handle_event("change_class", %{"ammo_type" => %{"class" => "pistol"}}, socket) do | ||||||
|     {:noreply, socket |> assign(:class, :pistol) |> display_shot_groups()} |     {:noreply, socket |> assign(:class, :pistol) |> display_shot_records()} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def handle_event("change_class", %{"ammo_type" => %{"class" => _all}}, socket) do |   def handle_event("change_class", %{"ammo_type" => %{"class" => _all}}, socket) do | ||||||
|     {:noreply, socket |> assign(:class, :all) |> display_shot_groups()} |     {:noreply, socket |> assign(:class, :all) |> display_shot_records()} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @spec display_shot_groups(Socket.t()) :: Socket.t() |   @spec display_shot_records(Socket.t()) :: Socket.t() | ||||||
|   defp display_shot_groups( |   defp display_shot_records( | ||||||
|          %{assigns: %{class: class, search: search, current_user: current_user}} = socket |          %{assigns: %{class: class, search: search, current_user: current_user}} = socket | ||||||
|        ) do |        ) do | ||||||
|     shot_groups = ActivityLog.list_shot_groups(search, class, current_user) |     shot_records = ActivityLog.list_shot_records(search, class, current_user) | ||||||
|     packs = Ammo.list_staged_packs(current_user) |     packs = Ammo.list_staged_packs(current_user) | ||||||
|     chart_data = shot_groups |> get_chart_data_for_shot_group() |     chart_data = shot_records |> get_chart_data_for_shot_record() | ||||||
|     original_counts = packs |> Ammo.get_original_counts(current_user) |     original_counts = packs |> Ammo.get_original_counts(current_user) | ||||||
|     cprs = packs |> Ammo.get_cprs(current_user) |     cprs = packs |> Ammo.get_cprs(current_user) | ||||||
|     last_used_dates = packs |> ActivityLog.get_last_used_dates(current_user) |     last_used_dates = packs |> ActivityLog.get_last_used_dates(current_user) | ||||||
| @@ -136,14 +136,14 @@ defmodule CanneryWeb.RangeLive.Index do | |||||||
|       cprs: cprs, |       cprs: cprs, | ||||||
|       last_used_dates: last_used_dates, |       last_used_dates: last_used_dates, | ||||||
|       chart_data: chart_data, |       chart_data: chart_data, | ||||||
|       shot_groups: shot_groups, |       shot_records: shot_records, | ||||||
|       shot_record_count: shot_record_count |       shot_record_count: shot_record_count | ||||||
|     ) |     ) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @spec get_chart_data_for_shot_group([ShotGroup.t()]) :: [map()] |   @spec get_chart_data_for_shot_record([ShotRecord.t()]) :: [map()] | ||||||
|   defp get_chart_data_for_shot_group(shot_groups) do |   defp get_chart_data_for_shot_record(shot_records) do | ||||||
|     shot_groups |     shot_records | ||||||
|     |> Enum.group_by(fn %{date: date} -> date end, fn %{count: count} -> count end) |     |> Enum.group_by(fn %{date: date} -> date end, fn %{count: count} -> count end) | ||||||
|     |> Enum.map(fn {date, rounds} -> |     |> Enum.map(fn {date, rounds} -> | ||||||
|       sum = Enum.sum(rounds) |       sum = Enum.sum(rounds) | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ | |||||||
|         </button> |         </button> | ||||||
|  |  | ||||||
|         <.link |         <.link | ||||||
|           patch={Routes.range_index_path(Endpoint, :add_shot_group, pack)} |           patch={Routes.range_index_path(Endpoint, :add_shot_record, pack)} | ||||||
|           class="btn btn-primary" |           class="btn btn-primary" | ||||||
|         > |         > | ||||||
|           <%= dgettext("actions", "Record shots") %> |           <%= dgettext("actions", "Record shots") %> | ||||||
| @@ -117,26 +117,26 @@ | |||||||
|       </.form> |       </.form> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|     <%= if @shot_groups |> Enum.empty?() do %> |     <%= if @shot_records |> Enum.empty?() do %> | ||||||
|       <h1 class="title text-xl text-primary-600"> |       <h1 class="title text-xl text-primary-600"> | ||||||
|         <%= gettext("No shots recorded") %> |         <%= gettext("No shots recorded") %> | ||||||
|         <%= display_emoji("😔") %> |         <%= display_emoji("😔") %> | ||||||
|       </h1> |       </h1> | ||||||
|     <% else %> |     <% else %> | ||||||
|       <.live_component |       <.live_component | ||||||
|         module={CanneryWeb.Components.ShotGroupTableComponent} |         module={CanneryWeb.Components.ShotRecordTableComponent} | ||||||
|         id="shot_groups_index_table" |         id="shot_records_index_table" | ||||||
|         shot_groups={@shot_groups} |         shot_records={@shot_records} | ||||||
|         current_user={@current_user} |         current_user={@current_user} | ||||||
|       > |       > | ||||||
|         <:actions :let={shot_group}> |         <:actions :let={shot_record}> | ||||||
|           <div class="px-4 py-2 space-x-4 flex justify-center items-center"> |           <div class="px-4 py-2 space-x-4 flex justify-center items-center"> | ||||||
|             <.link |             <.link | ||||||
|               patch={Routes.range_index_path(Endpoint, :edit, shot_group)} |               patch={Routes.range_index_path(Endpoint, :edit, shot_record)} | ||||||
|               class="text-primary-600 link" |               class="text-primary-600 link" | ||||||
|               aria-label={ |               aria-label={ | ||||||
|                 dgettext("actions", "Edit shot record of %{shot_group_count} shots", |                 dgettext("actions", "Edit shot record of %{shot_record_count} shots", | ||||||
|                   shot_group_count: shot_group.count |                   shot_record_count: shot_record.count | ||||||
|                 ) |                 ) | ||||||
|               } |               } | ||||||
|             > |             > | ||||||
| @@ -147,13 +147,13 @@ | |||||||
|               href="#" |               href="#" | ||||||
|               class="text-primary-600 link" |               class="text-primary-600 link" | ||||||
|               phx-click="delete" |               phx-click="delete" | ||||||
|               phx-value-id={shot_group.id} |               phx-value-id={shot_record.id} | ||||||
|               data-confirm={ |               data-confirm={ | ||||||
|                 dgettext("prompts", "Are you sure you want to delete this shot record?") |                 dgettext("prompts", "Are you sure you want to delete this shot record?") | ||||||
|               } |               } | ||||||
|               aria-label={ |               aria-label={ | ||||||
|                 dgettext("actions", "Delete shot record of %{shot_group_count} shots", |                 dgettext("actions", "Delete shot record of %{shot_record_count} shots", | ||||||
|                   shot_group_count: shot_group.count |                   shot_record_count: shot_record.count | ||||||
|                 ) |                 ) | ||||||
|               } |               } | ||||||
|             > |             > | ||||||
| @@ -171,18 +171,18 @@ | |||||||
|     <.modal return_to={Routes.range_index_path(Endpoint, :index)}> |     <.modal return_to={Routes.range_index_path(Endpoint, :index)}> | ||||||
|       <.live_component |       <.live_component | ||||||
|         module={CanneryWeb.RangeLive.FormComponent} |         module={CanneryWeb.RangeLive.FormComponent} | ||||||
|         id={@shot_group.id} |         id={@shot_record.id} | ||||||
|         title={@page_title} |         title={@page_title} | ||||||
|         action={@live_action} |         action={@live_action} | ||||||
|         shot_group={@shot_group} |         shot_record={@shot_record} | ||||||
|         return_to={Routes.range_index_path(Endpoint, :index)} |         return_to={Routes.range_index_path(Endpoint, :index)} | ||||||
|         current_user={@current_user} |         current_user={@current_user} | ||||||
|       /> |       /> | ||||||
|     </.modal> |     </.modal> | ||||||
|   <% :add_shot_group -> %> |   <% :add_shot_record -> %> | ||||||
|     <.modal return_to={Routes.range_index_path(Endpoint, :index)}> |     <.modal return_to={Routes.range_index_path(Endpoint, :index)}> | ||||||
|       <.live_component |       <.live_component | ||||||
|         module={CanneryWeb.Components.AddShotGroupComponent} |         module={CanneryWeb.Components.AddShotRecordComponent} | ||||||
|         id={:new} |         id={:new} | ||||||
|         title={@page_title} |         title={@page_title} | ||||||
|         action={@live_action} |         action={@live_action} | ||||||
|   | |||||||
| @@ -93,19 +93,19 @@ defmodule CanneryWeb.Router do | |||||||
|     live "/ammo/new", PackLive.Index, :new |     live "/ammo/new", PackLive.Index, :new | ||||||
|     live "/ammo/edit/:id", PackLive.Index, :edit |     live "/ammo/edit/:id", PackLive.Index, :edit | ||||||
|     live "/ammo/clone/:id", PackLive.Index, :clone |     live "/ammo/clone/:id", PackLive.Index, :clone | ||||||
|     live "/ammo/add_shot_group/:id", PackLive.Index, :add_shot_group |     live "/ammo/add_shot_record/:id", PackLive.Index, :add_shot_record | ||||||
|     live "/ammo/move/:id", PackLive.Index, :move |     live "/ammo/move/:id", PackLive.Index, :move | ||||||
|     live "/ammo/search/:search", PackLive.Index, :search |     live "/ammo/search/:search", PackLive.Index, :search | ||||||
|  |  | ||||||
|     live "/ammo/show/:id", PackLive.Show, :show |     live "/ammo/show/:id", PackLive.Show, :show | ||||||
|     live "/ammo/show/edit/:id", PackLive.Show, :edit |     live "/ammo/show/edit/:id", PackLive.Show, :edit | ||||||
|     live "/ammo/show/add_shot_group/:id", PackLive.Show, :add_shot_group |     live "/ammo/show/add_shot_record/:id", PackLive.Show, :add_shot_record | ||||||
|     live "/ammo/show/move/:id", PackLive.Show, :move |     live "/ammo/show/move/:id", PackLive.Show, :move | ||||||
|     live "/ammo/show/:id/edit/:shot_group_id", PackLive.Show, :edit_shot_group |     live "/ammo/show/:id/edit/:shot_record_id", PackLive.Show, :edit_shot_record | ||||||
|  |  | ||||||
|     live "/range", RangeLive.Index, :index |     live "/range", RangeLive.Index, :index | ||||||
|     live "/range/edit/:id", RangeLive.Index, :edit |     live "/range/edit/:id", RangeLive.Index, :edit | ||||||
|     live "/range/add_shot_group/:id", RangeLive.Index, :add_shot_group |     live "/range/add_shot_record/:id", RangeLive.Index, :add_shot_record | ||||||
|     live "/range/search/:search", RangeLive.Index, :search |     live "/range/search/:search", RangeLive.Index, :search | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -120,7 +120,6 @@ msgstr "" | |||||||
| msgid "Reset password" | msgid "Reset password" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:57 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:57 | #: lib/cannery_web/live/container_live/form_component.html.heex:57 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | ||||||
| @@ -276,12 +275,6 @@ msgstr "" | |||||||
| msgid "Delete invite for %{invite_name}" | msgid "Delete invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:160 |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:155 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Delete shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -305,16 +298,6 @@ msgstr "" | |||||||
| msgid "Edit invite for %{invite_name}" | msgid "Edit invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:145 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot group of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:138 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:120 | #: lib/cannery_web/live/pack_live/index.html.heex:120 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Stage" | msgid "Stage" | ||||||
| @@ -358,3 +341,15 @@ msgstr "" | |||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "View pack of %{pack_count} bullets" | msgid "View pack of %{pack_count} bullets" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:160 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:155 | ||||||
|  | #, elixir-autogen, elixir-format | ||||||
|  | msgid "Delete shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:145 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:138 | ||||||
|  | #, elixir-autogen, elixir-format | ||||||
|  | msgid "Edit shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|   | |||||||
| @@ -133,7 +133,6 @@ msgstr "Bestätigungsmail erneut senden" | |||||||
| msgid "Reset password" | msgid "Reset password" | ||||||
| msgstr "Passwort zurücksetzen" | msgstr "Passwort zurücksetzen" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:57 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:57 | #: lib/cannery_web/live/container_live/form_component.html.heex:57 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | ||||||
| @@ -289,12 +288,6 @@ msgstr "" | |||||||
| msgid "Delete invite for %{invite_name}" | msgid "Delete invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:160 |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:155 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Delete shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -318,16 +311,6 @@ msgstr "" | |||||||
| msgid "Edit invite for %{invite_name}" | msgid "Edit invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:145 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot group of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:138 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:120 | #: lib/cannery_web/live/pack_live/index.html.heex:120 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Stage" | msgid "Stage" | ||||||
| @@ -371,3 +354,15 @@ msgstr "" | |||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "View pack of %{pack_count} bullets" | msgid "View pack of %{pack_count} bullets" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:160 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:155 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Delete shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:145 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:138 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Edit shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ msgid "Admins:" | |||||||
| msgstr "Admins:" | msgstr "Admins:" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/core_components/topbar.html.heex:58 | #: lib/cannery_web/components/core_components/topbar.html.heex:58 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:41 | #: lib/cannery_web/components/shot_group_table_component.ex:44 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:75 | #: lib/cannery_web/live/pack_live/index.ex:75 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:84 | #: lib/cannery_web/live/pack_live/index.ex:84 | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:3 | #: lib/cannery_web/live/pack_live/index.html.heex:3 | ||||||
| @@ -290,8 +290,7 @@ msgstr "Keine Einladung" | |||||||
| msgid "No tags" | msgid "No tags" | ||||||
| msgstr "Keine Tags" | msgstr "Keine Tags" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:38 | #: lib/cannery_web/components/shot_group_table_component.ex:46 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:43 |  | ||||||
| #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:91 | #: lib/cannery_web/live/pack_live/show.ex:91 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:30 | #: lib/cannery_web/live/range_live/form_component.html.heex:30 | ||||||
| @@ -445,8 +444,7 @@ msgstr "Schießplatz" | |||||||
| msgid "Range day" | msgid "Range day" | ||||||
| msgstr "Range Day" | msgstr "Range Day" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:49 | #: lib/cannery_web/components/shot_group_table_component.ex:47 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:44 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:92 | #: lib/cannery_web/live/pack_live/show.ex:92 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:41 | #: lib/cannery_web/live/range_live/form_component.html.heex:41 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -463,7 +461,6 @@ msgstr "Schüsse abgegeben" | |||||||
| msgid "No ammo staged" | msgid "No ammo staged" | ||||||
| msgstr "Keine Munition selektiert" | msgstr "Keine Munition selektiert" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:3 |  | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:35 | #: lib/cannery_web/live/pack_live/index.ex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Record shots" | msgid "Record shots" | ||||||
| @@ -486,13 +483,7 @@ msgstr "Neue Schießkladde" | |||||||
| msgid "No shots recorded" | msgid "No shots recorded" | ||||||
| msgstr "Keine Schüsse dokumentiert" | msgstr "Keine Schüsse dokumentiert" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:22 | #: lib/cannery_web/components/shot_group_table_component.ex:45 | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:26 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Rounds left" |  | ||||||
| msgstr "Patronen verbleibend" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:42 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:90 | #: lib/cannery_web/live/pack_live/show.ex:90 | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:69 | #: lib/cannery_web/live/range_live/index.html.heex:69 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -872,11 +863,6 @@ msgstr "" | |||||||
| msgid "Used rounds:" | msgid "Used rounds:" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:34 |  | ||||||
| #, elixir-autogen, elixir-format, fuzzy |  | ||||||
| msgid "Used up!" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:71 | #: lib/cannery_web/live/range_live/index.html.heex:71 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Rounds shot chart" | msgid "Rounds shot chart" | ||||||
| @@ -1212,7 +1198,6 @@ msgstr "" | |||||||
| msgid "Centerfire" | msgid "Centerfire" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:43 |  | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:35 | #: lib/cannery_web/live/range_live/form_component.html.heex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Really great weather" | msgid "Really great weather" | ||||||
| @@ -1222,7 +1207,7 @@ msgstr "" | |||||||
| #: lib/cannery_web/components/container_table_component.ex:67 | #: lib/cannery_web/components/container_table_component.ex:67 | ||||||
| #: lib/cannery_web/components/move_pack_component.ex:68 | #: lib/cannery_web/components/move_pack_component.ex:68 | ||||||
| #: lib/cannery_web/components/pack_table_component.ex:59 | #: lib/cannery_web/components/pack_table_component.ex:59 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:45 | #: lib/cannery_web/components/shot_group_table_component.ex:48 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:93 | #: lib/cannery_web/live/pack_live/show.ex:93 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Actions" | msgid "Actions" | ||||||
|   | |||||||
| @@ -128,7 +128,6 @@ msgstr "Passwort erfolgreich geändert." | |||||||
| msgid "Please check your email to verify your account" | msgid "Please check your email to verify your account" | ||||||
| msgstr "Bitte überprüfen Sie ihre Mailbox und bestätigen Sie das Nutzerkonto" | msgstr "Bitte überprüfen Sie ihre Mailbox und bestätigen Sie das Nutzerkonto" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:59 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:59 | #: lib/cannery_web/live/container_live/form_component.html.heex:59 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | ||||||
|   | |||||||
| @@ -26,7 +26,7 @@ msgid "Admins:" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/core_components/topbar.html.heex:58 | #: lib/cannery_web/components/core_components/topbar.html.heex:58 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:41 | #: lib/cannery_web/components/shot_group_table_component.ex:44 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:75 | #: lib/cannery_web/live/pack_live/index.ex:75 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:84 | #: lib/cannery_web/live/pack_live/index.ex:84 | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:3 | #: lib/cannery_web/live/pack_live/index.html.heex:3 | ||||||
| @@ -286,8 +286,7 @@ msgstr "" | |||||||
| msgid "No tags" | msgid "No tags" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:38 | #: lib/cannery_web/components/shot_group_table_component.ex:46 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:43 |  | ||||||
| #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:91 | #: lib/cannery_web/live/pack_live/show.ex:91 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:30 | #: lib/cannery_web/live/range_live/form_component.html.heex:30 | ||||||
| @@ -439,8 +438,7 @@ msgstr "" | |||||||
| msgid "Range day" | msgid "Range day" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:49 | #: lib/cannery_web/components/shot_group_table_component.ex:47 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:44 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:92 | #: lib/cannery_web/live/pack_live/show.ex:92 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:41 | #: lib/cannery_web/live/range_live/form_component.html.heex:41 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -457,7 +455,6 @@ msgstr "" | |||||||
| msgid "No ammo staged" | msgid "No ammo staged" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:3 |  | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:35 | #: lib/cannery_web/live/pack_live/index.ex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Record shots" | msgid "Record shots" | ||||||
| @@ -480,13 +477,7 @@ msgstr "" | |||||||
| msgid "No shots recorded" | msgid "No shots recorded" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:22 | #: lib/cannery_web/components/shot_group_table_component.ex:45 | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:26 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Rounds left" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:42 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:90 | #: lib/cannery_web/live/pack_live/show.ex:90 | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:69 | #: lib/cannery_web/live/range_live/index.html.heex:69 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -866,11 +857,6 @@ msgstr "" | |||||||
| msgid "Used rounds:" | msgid "Used rounds:" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:34 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Used up!" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:71 | #: lib/cannery_web/live/range_live/index.html.heex:71 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Rounds shot chart" | msgid "Rounds shot chart" | ||||||
| @@ -1195,7 +1181,6 @@ msgstr "" | |||||||
| msgid "Centerfire" | msgid "Centerfire" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:43 |  | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:35 | #: lib/cannery_web/live/range_live/form_component.html.heex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Really great weather" | msgid "Really great weather" | ||||||
| @@ -1205,7 +1190,7 @@ msgstr "" | |||||||
| #: lib/cannery_web/components/container_table_component.ex:67 | #: lib/cannery_web/components/container_table_component.ex:67 | ||||||
| #: lib/cannery_web/components/move_pack_component.ex:68 | #: lib/cannery_web/components/move_pack_component.ex:68 | ||||||
| #: lib/cannery_web/components/pack_table_component.ex:59 | #: lib/cannery_web/components/pack_table_component.ex:59 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:45 | #: lib/cannery_web/components/shot_group_table_component.ex:48 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:93 | #: lib/cannery_web/live/pack_live/show.ex:93 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Actions" | msgid "Actions" | ||||||
|   | |||||||
| @@ -120,7 +120,6 @@ msgstr "" | |||||||
| msgid "Reset password" | msgid "Reset password" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:57 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:57 | #: lib/cannery_web/live/container_live/form_component.html.heex:57 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | ||||||
| @@ -276,12 +275,6 @@ msgstr "" | |||||||
| msgid "Delete invite for %{invite_name}" | msgid "Delete invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:160 |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:155 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Delete shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -305,16 +298,6 @@ msgstr "" | |||||||
| msgid "Edit invite for %{invite_name}" | msgid "Edit invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:145 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot group of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:138 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:120 | #: lib/cannery_web/live/pack_live/index.html.heex:120 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Stage" | msgid "Stage" | ||||||
| @@ -358,3 +341,15 @@ msgstr "" | |||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "View pack of %{pack_count} bullets" | msgid "View pack of %{pack_count} bullets" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:160 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:155 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Delete shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:145 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:138 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Edit shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|   | |||||||
| @@ -26,7 +26,7 @@ msgid "Admins:" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/core_components/topbar.html.heex:58 | #: lib/cannery_web/components/core_components/topbar.html.heex:58 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:41 | #: lib/cannery_web/components/shot_group_table_component.ex:44 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:75 | #: lib/cannery_web/live/pack_live/index.ex:75 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:84 | #: lib/cannery_web/live/pack_live/index.ex:84 | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:3 | #: lib/cannery_web/live/pack_live/index.html.heex:3 | ||||||
| @@ -286,8 +286,7 @@ msgstr "" | |||||||
| msgid "No tags" | msgid "No tags" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:38 | #: lib/cannery_web/components/shot_group_table_component.ex:46 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:43 |  | ||||||
| #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:91 | #: lib/cannery_web/live/pack_live/show.ex:91 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:30 | #: lib/cannery_web/live/range_live/form_component.html.heex:30 | ||||||
| @@ -439,8 +438,7 @@ msgstr "" | |||||||
| msgid "Range day" | msgid "Range day" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:49 | #: lib/cannery_web/components/shot_group_table_component.ex:47 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:44 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:92 | #: lib/cannery_web/live/pack_live/show.ex:92 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:41 | #: lib/cannery_web/live/range_live/form_component.html.heex:41 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -457,7 +455,6 @@ msgstr "" | |||||||
| msgid "No ammo staged" | msgid "No ammo staged" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:3 |  | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:35 | #: lib/cannery_web/live/pack_live/index.ex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Record shots" | msgid "Record shots" | ||||||
| @@ -480,13 +477,7 @@ msgstr "" | |||||||
| msgid "No shots recorded" | msgid "No shots recorded" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:22 | #: lib/cannery_web/components/shot_group_table_component.ex:45 | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:26 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Rounds left" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:42 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:90 | #: lib/cannery_web/live/pack_live/show.ex:90 | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:69 | #: lib/cannery_web/live/range_live/index.html.heex:69 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -866,11 +857,6 @@ msgstr "" | |||||||
| msgid "Used rounds:" | msgid "Used rounds:" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:34 |  | ||||||
| #, elixir-autogen, elixir-format, fuzzy |  | ||||||
| msgid "Used up!" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:71 | #: lib/cannery_web/live/range_live/index.html.heex:71 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Rounds shot chart" | msgid "Rounds shot chart" | ||||||
| @@ -1195,7 +1181,6 @@ msgstr "" | |||||||
| msgid "Centerfire" | msgid "Centerfire" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:43 |  | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:35 | #: lib/cannery_web/live/range_live/form_component.html.heex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Really great weather" | msgid "Really great weather" | ||||||
| @@ -1205,7 +1190,7 @@ msgstr "" | |||||||
| #: lib/cannery_web/components/container_table_component.ex:67 | #: lib/cannery_web/components/container_table_component.ex:67 | ||||||
| #: lib/cannery_web/components/move_pack_component.ex:68 | #: lib/cannery_web/components/move_pack_component.ex:68 | ||||||
| #: lib/cannery_web/components/pack_table_component.ex:59 | #: lib/cannery_web/components/pack_table_component.ex:59 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:45 | #: lib/cannery_web/components/shot_group_table_component.ex:48 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:93 | #: lib/cannery_web/live/pack_live/show.ex:93 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Actions" | msgid "Actions" | ||||||
|   | |||||||
| @@ -109,7 +109,6 @@ msgstr "" | |||||||
| msgid "Please check your email to verify your account" | msgid "Please check your email to verify your account" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:59 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:59 | #: lib/cannery_web/live/container_live/form_component.html.heex:59 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | ||||||
|   | |||||||
| @@ -133,7 +133,6 @@ msgstr "Reenviar instrucciones de confirmación" | |||||||
| msgid "Reset password" | msgid "Reset password" | ||||||
| msgstr "Resetear contraseña" | msgstr "Resetear contraseña" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:57 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:57 | #: lib/cannery_web/live/container_live/form_component.html.heex:57 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | ||||||
| @@ -289,12 +288,6 @@ msgstr "" | |||||||
| msgid "Delete invite for %{invite_name}" | msgid "Delete invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:160 |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:155 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Delete shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -318,16 +311,6 @@ msgstr "" | |||||||
| msgid "Edit invite for %{invite_name}" | msgid "Edit invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:145 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot group of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:138 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:120 | #: lib/cannery_web/live/pack_live/index.html.heex:120 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Stage" | msgid "Stage" | ||||||
| @@ -371,3 +354,15 @@ msgstr "" | |||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "View pack of %{pack_count} bullets" | msgid "View pack of %{pack_count} bullets" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:160 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:155 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Delete shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:145 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:138 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Edit shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ msgid "Admins:" | |||||||
| msgstr "Aministradores:" | msgstr "Aministradores:" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/core_components/topbar.html.heex:58 | #: lib/cannery_web/components/core_components/topbar.html.heex:58 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:41 | #: lib/cannery_web/components/shot_group_table_component.ex:44 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:75 | #: lib/cannery_web/live/pack_live/index.ex:75 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:84 | #: lib/cannery_web/live/pack_live/index.ex:84 | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:3 | #: lib/cannery_web/live/pack_live/index.html.heex:3 | ||||||
| @@ -290,8 +290,7 @@ msgstr "Sin invitaciones" | |||||||
| msgid "No tags" | msgid "No tags" | ||||||
| msgstr "Sin etiquetas" | msgstr "Sin etiquetas" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:38 | #: lib/cannery_web/components/shot_group_table_component.ex:46 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:43 |  | ||||||
| #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:91 | #: lib/cannery_web/live/pack_live/show.ex:91 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:30 | #: lib/cannery_web/live/range_live/form_component.html.heex:30 | ||||||
| @@ -446,8 +445,7 @@ msgstr "Campo de tiro" | |||||||
| msgid "Range day" | msgid "Range day" | ||||||
| msgstr "Día de disparar" | msgstr "Día de disparar" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:49 | #: lib/cannery_web/components/shot_group_table_component.ex:47 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:44 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:92 | #: lib/cannery_web/live/pack_live/show.ex:92 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:41 | #: lib/cannery_web/live/range_live/form_component.html.heex:41 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -464,7 +462,6 @@ msgstr "Tiros disparados" | |||||||
| msgid "No ammo staged" | msgid "No ammo staged" | ||||||
| msgstr "No hay munición preparada" | msgstr "No hay munición preparada" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:3 |  | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:35 | #: lib/cannery_web/live/pack_live/index.ex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Record shots" | msgid "Record shots" | ||||||
| @@ -487,13 +484,7 @@ msgstr "Nuevos Tiros Récord" | |||||||
| msgid "No shots recorded" | msgid "No shots recorded" | ||||||
| msgstr "No se han grabado tiros" | msgstr "No se han grabado tiros" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:22 | #: lib/cannery_web/components/shot_group_table_component.ex:45 | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:26 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Rounds left" |  | ||||||
| msgstr "Balas restantes" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:42 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:90 | #: lib/cannery_web/live/pack_live/show.ex:90 | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:69 | #: lib/cannery_web/live/range_live/index.html.heex:69 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -874,11 +865,6 @@ msgstr "Balas usadas" | |||||||
| msgid "Used rounds:" | msgid "Used rounds:" | ||||||
| msgstr "Balas usadas:" | msgstr "Balas usadas:" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:34 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Used up!" |  | ||||||
| msgstr "¡Acabada!" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:71 | #: lib/cannery_web/live/range_live/index.html.heex:71 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Rounds shot chart" | msgid "Rounds shot chart" | ||||||
| @@ -1214,7 +1200,6 @@ msgstr "" | |||||||
| msgid "Centerfire" | msgid "Centerfire" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:43 |  | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:35 | #: lib/cannery_web/live/range_live/form_component.html.heex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Really great weather" | msgid "Really great weather" | ||||||
| @@ -1224,7 +1209,7 @@ msgstr "" | |||||||
| #: lib/cannery_web/components/container_table_component.ex:67 | #: lib/cannery_web/components/container_table_component.ex:67 | ||||||
| #: lib/cannery_web/components/move_pack_component.ex:68 | #: lib/cannery_web/components/move_pack_component.ex:68 | ||||||
| #: lib/cannery_web/components/pack_table_component.ex:59 | #: lib/cannery_web/components/pack_table_component.ex:59 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:45 | #: lib/cannery_web/components/shot_group_table_component.ex:48 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:93 | #: lib/cannery_web/live/pack_live/show.ex:93 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Actions" | msgid "Actions" | ||||||
|   | |||||||
| @@ -128,7 +128,6 @@ msgstr "Contraseña cambiada exitosamente." | |||||||
| msgid "Please check your email to verify your account" | msgid "Please check your email to verify your account" | ||||||
| msgstr "Por favor chequea el correo para verificar tu cuenta" | msgstr "Por favor chequea el correo para verificar tu cuenta" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:59 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:59 | #: lib/cannery_web/live/container_live/form_component.html.heex:59 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | ||||||
|   | |||||||
| @@ -133,7 +133,6 @@ msgstr "Renvoyer les instructions de confirmation" | |||||||
| msgid "Reset password" | msgid "Reset password" | ||||||
| msgstr "Réinitialisé le mot de passe" | msgstr "Réinitialisé le mot de passe" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:57 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:57 | #: lib/cannery_web/live/container_live/form_component.html.heex:57 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | ||||||
| @@ -289,12 +288,6 @@ msgstr "" | |||||||
| msgid "Delete invite for %{invite_name}" | msgid "Delete invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:160 |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:155 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Delete shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -318,16 +311,6 @@ msgstr "" | |||||||
| msgid "Edit invite for %{invite_name}" | msgid "Edit invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:145 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot group of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:138 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:120 | #: lib/cannery_web/live/pack_live/index.html.heex:120 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Stage" | msgid "Stage" | ||||||
| @@ -371,3 +354,15 @@ msgstr "" | |||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "View pack of %{pack_count} bullets" | msgid "View pack of %{pack_count} bullets" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:160 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:155 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Delete shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:145 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:138 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Edit shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ msgid "Admins:" | |||||||
| msgstr "Administrateur·ices :" | msgstr "Administrateur·ices :" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/core_components/topbar.html.heex:58 | #: lib/cannery_web/components/core_components/topbar.html.heex:58 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:41 | #: lib/cannery_web/components/shot_group_table_component.ex:44 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:75 | #: lib/cannery_web/live/pack_live/index.ex:75 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:84 | #: lib/cannery_web/live/pack_live/index.ex:84 | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:3 | #: lib/cannery_web/live/pack_live/index.html.heex:3 | ||||||
| @@ -290,8 +290,7 @@ msgstr "Aucune invitation" | |||||||
| msgid "No tags" | msgid "No tags" | ||||||
| msgstr "Aucun tag" | msgstr "Aucun tag" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:38 | #: lib/cannery_web/components/shot_group_table_component.ex:46 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:43 |  | ||||||
| #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:91 | #: lib/cannery_web/live/pack_live/show.ex:91 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:30 | #: lib/cannery_web/live/range_live/form_component.html.heex:30 | ||||||
| @@ -447,8 +446,7 @@ msgstr "Portée" | |||||||
| msgid "Range day" | msgid "Range day" | ||||||
| msgstr "Journée de stand" | msgstr "Journée de stand" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:49 | #: lib/cannery_web/components/shot_group_table_component.ex:47 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:44 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:92 | #: lib/cannery_web/live/pack_live/show.ex:92 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:41 | #: lib/cannery_web/live/range_live/form_component.html.heex:41 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -465,7 +463,6 @@ msgstr "Tirs réalisés" | |||||||
| msgid "No ammo staged" | msgid "No ammo staged" | ||||||
| msgstr "Aucune munition sélectionnée" | msgstr "Aucune munition sélectionnée" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:3 |  | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:35 | #: lib/cannery_web/live/pack_live/index.ex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Record shots" | msgid "Record shots" | ||||||
| @@ -488,13 +485,7 @@ msgstr "Nouveaux enregistrements de tir" | |||||||
| msgid "No shots recorded" | msgid "No shots recorded" | ||||||
| msgstr "Aucun tir enregistré" | msgstr "Aucun tir enregistré" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:22 | #: lib/cannery_web/components/shot_group_table_component.ex:45 | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:26 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Rounds left" |  | ||||||
| msgstr "Cartouches restantes" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:42 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:90 | #: lib/cannery_web/live/pack_live/show.ex:90 | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:69 | #: lib/cannery_web/live/range_live/index.html.heex:69 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -875,11 +866,6 @@ msgstr "" | |||||||
| msgid "Used rounds:" | msgid "Used rounds:" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:34 |  | ||||||
| #, elixir-autogen, elixir-format, fuzzy |  | ||||||
| msgid "Used up!" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:71 | #: lib/cannery_web/live/range_live/index.html.heex:71 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Rounds shot chart" | msgid "Rounds shot chart" | ||||||
| @@ -1215,7 +1201,6 @@ msgstr "" | |||||||
| msgid "Centerfire" | msgid "Centerfire" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:43 |  | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:35 | #: lib/cannery_web/live/range_live/form_component.html.heex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Really great weather" | msgid "Really great weather" | ||||||
| @@ -1225,7 +1210,7 @@ msgstr "" | |||||||
| #: lib/cannery_web/components/container_table_component.ex:67 | #: lib/cannery_web/components/container_table_component.ex:67 | ||||||
| #: lib/cannery_web/components/move_pack_component.ex:68 | #: lib/cannery_web/components/move_pack_component.ex:68 | ||||||
| #: lib/cannery_web/components/pack_table_component.ex:59 | #: lib/cannery_web/components/pack_table_component.ex:59 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:45 | #: lib/cannery_web/components/shot_group_table_component.ex:48 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:93 | #: lib/cannery_web/live/pack_live/show.ex:93 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Actions" | msgid "Actions" | ||||||
|   | |||||||
| @@ -129,7 +129,6 @@ msgstr "Mot de passe mis à jour avec succès." | |||||||
| msgid "Please check your email to verify your account" | msgid "Please check your email to verify your account" | ||||||
| msgstr "Veuillez vérifier votre mél pour confirmer votre compte" | msgstr "Veuillez vérifier votre mél pour confirmer votre compte" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:59 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:59 | #: lib/cannery_web/live/container_live/form_component.html.heex:59 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | ||||||
|   | |||||||
| @@ -131,7 +131,6 @@ msgstr "" | |||||||
| msgid "Reset password" | msgid "Reset password" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:57 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:350 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:57 | #: lib/cannery_web/live/container_live/form_component.html.heex:57 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | #: lib/cannery_web/live/invite_live/form_component.html.heex:35 | ||||||
| @@ -287,12 +286,6 @@ msgstr "" | |||||||
| msgid "Delete invite for %{invite_name}" | msgid "Delete invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:160 |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:155 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Delete shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | #: lib/cannery_web/live/ammo_type_live/index.html.heex:100 | ||||||
| #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | #: lib/cannery_web/live/ammo_type_live/show.html.heex:19 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -316,16 +309,6 @@ msgstr "" | |||||||
| msgid "Edit invite for %{invite_name}" | msgid "Edit invite for %{invite_name}" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:145 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot group of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:138 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Edit shot record of %{shot_group_count} shots" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:120 | #: lib/cannery_web/live/pack_live/index.html.heex:120 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Stage" | msgid "Stage" | ||||||
| @@ -369,3 +352,15 @@ msgstr "" | |||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "View pack of %{pack_count} bullets" | msgid "View pack of %{pack_count} bullets" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:160 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:155 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Delete shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #: lib/cannery_web/live/pack_live/show.ex:145 | ||||||
|  | #: lib/cannery_web/live/range_live/index.html.heex:138 | ||||||
|  | #, elixir-autogen, elixir-format, fuzzy | ||||||
|  | msgid "Edit shot record of %{shot_record_count} shots" | ||||||
|  | msgstr "" | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ msgid "Admins:" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/core_components/topbar.html.heex:58 | #: lib/cannery_web/components/core_components/topbar.html.heex:58 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:41 | #: lib/cannery_web/components/shot_group_table_component.ex:44 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:75 | #: lib/cannery_web/live/pack_live/index.ex:75 | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:84 | #: lib/cannery_web/live/pack_live/index.ex:84 | ||||||
| #: lib/cannery_web/live/pack_live/index.html.heex:3 | #: lib/cannery_web/live/pack_live/index.html.heex:3 | ||||||
| @@ -288,8 +288,7 @@ msgstr "" | |||||||
| msgid "No tags" | msgid "No tags" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:38 | #: lib/cannery_web/components/shot_group_table_component.ex:46 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:43 |  | ||||||
| #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | #: lib/cannery_web/live/pack_live/form_component.html.heex:50 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:91 | #: lib/cannery_web/live/pack_live/show.ex:91 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:30 | #: lib/cannery_web/live/range_live/form_component.html.heex:30 | ||||||
| @@ -441,8 +440,7 @@ msgstr "" | |||||||
| msgid "Range day" | msgid "Range day" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:49 | #: lib/cannery_web/components/shot_group_table_component.ex:47 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:44 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:92 | #: lib/cannery_web/live/pack_live/show.ex:92 | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:41 | #: lib/cannery_web/live/range_live/form_component.html.heex:41 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -459,7 +457,6 @@ msgstr "" | |||||||
| msgid "No ammo staged" | msgid "No ammo staged" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:3 |  | ||||||
| #: lib/cannery_web/live/pack_live/index.ex:35 | #: lib/cannery_web/live/pack_live/index.ex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Record shots" | msgid "Record shots" | ||||||
| @@ -482,13 +479,7 @@ msgstr "" | |||||||
| msgid "No shots recorded" | msgid "No shots recorded" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:22 | #: lib/cannery_web/components/shot_group_table_component.ex:45 | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:26 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "Rounds left" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:42 |  | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:90 | #: lib/cannery_web/live/pack_live/show.ex:90 | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:69 | #: lib/cannery_web/live/range_live/index.html.heex:69 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| @@ -868,11 +859,6 @@ msgstr "" | |||||||
| msgid "Used rounds:" | msgid "Used rounds:" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:34 |  | ||||||
| #, elixir-autogen, elixir-format, fuzzy |  | ||||||
| msgid "Used up!" |  | ||||||
| msgstr "" |  | ||||||
|  |  | ||||||
| #: lib/cannery_web/live/range_live/index.html.heex:71 | #: lib/cannery_web/live/range_live/index.html.heex:71 | ||||||
| #, elixir-autogen, elixir-format, fuzzy | #, elixir-autogen, elixir-format, fuzzy | ||||||
| msgid "Rounds shot chart" | msgid "Rounds shot chart" | ||||||
| @@ -1206,7 +1192,6 @@ msgstr "" | |||||||
| msgid "Centerfire" | msgid "Centerfire" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:43 |  | ||||||
| #: lib/cannery_web/live/range_live/form_component.html.heex:35 | #: lib/cannery_web/live/range_live/form_component.html.heex:35 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Really great weather" | msgid "Really great weather" | ||||||
| @@ -1216,7 +1201,7 @@ msgstr "" | |||||||
| #: lib/cannery_web/components/container_table_component.ex:67 | #: lib/cannery_web/components/container_table_component.ex:67 | ||||||
| #: lib/cannery_web/components/move_pack_component.ex:68 | #: lib/cannery_web/components/move_pack_component.ex:68 | ||||||
| #: lib/cannery_web/components/pack_table_component.ex:59 | #: lib/cannery_web/components/pack_table_component.ex:59 | ||||||
| #: lib/cannery_web/components/shot_group_table_component.ex:45 | #: lib/cannery_web/components/shot_group_table_component.ex:48 | ||||||
| #: lib/cannery_web/live/pack_live/show.ex:93 | #: lib/cannery_web/live/pack_live/show.ex:93 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "Actions" | msgid "Actions" | ||||||
|   | |||||||
| @@ -120,7 +120,6 @@ msgstr "" | |||||||
| msgid "Please check your email to verify your account" | msgid "Please check your email to verify your account" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:59 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:59 | #: lib/cannery_web/live/container_live/form_component.html.heex:59 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | ||||||
|   | |||||||
| @@ -109,7 +109,6 @@ msgstr "" | |||||||
| msgid "Please check your email to verify your account" | msgid "Please check your email to verify your account" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/cannery_web/components/add_shot_group_component.html.heex:59 |  | ||||||
| #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | #: lib/cannery_web/live/ammo_type_live/form_component.html.heex:351 | ||||||
| #: lib/cannery_web/live/container_live/form_component.html.heex:59 | #: lib/cannery_web/live/container_live/form_component.html.heex:59 | ||||||
| #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | #: lib/cannery_web/live/invite_live/form_component.html.heex:37 | ||||||
|   | |||||||
| @@ -5,11 +5,11 @@ defmodule Cannery.ActivityLogTest do | |||||||
|  |  | ||||||
|   use Cannery.DataCase |   use Cannery.DataCase | ||||||
|   import Cannery.Fixtures |   import Cannery.Fixtures | ||||||
|   alias Cannery.{ActivityLog, ActivityLog.ShotGroup, Ammo} |   alias Cannery.{ActivityLog, ActivityLog.ShotRecord, Ammo} | ||||||
|  |  | ||||||
|   @moduletag :activity_log_test |   @moduletag :activity_log_test | ||||||
|  |  | ||||||
|   describe "shot_groups" do |   describe "shot_records" do | ||||||
|     setup do |     setup do | ||||||
|       current_user = user_fixture() |       current_user = user_fixture() | ||||||
|       container = container_fixture(current_user) |       container = container_fixture(current_user) | ||||||
| @@ -18,9 +18,9 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       {1, [%{id: pack_id} = pack]} = |       {1, [%{id: pack_id} = pack]} = | ||||||
|         pack_fixture(%{count: 25}, ammo_type, container, current_user) |         pack_fixture(%{count: 25}, ammo_type, container, current_user) | ||||||
|  |  | ||||||
|       shot_group = |       shot_record = | ||||||
|         %{count: 5, date: ~N[2022-02-13 03:17:00], notes: "some notes"} |         %{count: 5, date: ~N[2022-02-13 03:17:00], notes: "some notes"} | ||||||
|         |> shot_group_fixture(current_user, pack) |         |> shot_record_fixture(current_user, pack) | ||||||
|  |  | ||||||
|       pack = pack_id |> Ammo.get_pack!(current_user) |       pack = pack_id |> Ammo.get_pack!(current_user) | ||||||
|  |  | ||||||
| @@ -29,7 +29,7 @@ defmodule Cannery.ActivityLogTest do | |||||||
|         container: container, |         container: container, | ||||||
|         ammo_type: ammo_type, |         ammo_type: ammo_type, | ||||||
|         pack: pack, |         pack: pack, | ||||||
|         shot_group: shot_group |         shot_record: shot_record | ||||||
|       ] |       ] | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -37,10 +37,10 @@ defmodule Cannery.ActivityLogTest do | |||||||
|          %{pack: pack, current_user: current_user} do |          %{pack: pack, current_user: current_user} do | ||||||
|       assert ActivityLog.get_shot_record_count!(current_user) == 1 |       assert ActivityLog.get_shot_record_count!(current_user) == 1 | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1, date: ~N[2022-02-13 03:17:00]}, current_user, pack) |       shot_record_fixture(%{count: 1, date: ~N[2022-02-13 03:17:00]}, current_user, pack) | ||||||
|       assert ActivityLog.get_shot_record_count!(current_user) == 2 |       assert ActivityLog.get_shot_record_count!(current_user) == 2 | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1, date: ~N[2022-02-13 03:17:00]}, current_user, pack) |       shot_record_fixture(%{count: 1, date: ~N[2022-02-13 03:17:00]}, current_user, pack) | ||||||
|       assert ActivityLog.get_shot_record_count!(current_user) == 3 |       assert ActivityLog.get_shot_record_count!(current_user) == 3 | ||||||
|  |  | ||||||
|       other_user = user_fixture() |       other_user = user_fixture() | ||||||
| @@ -49,83 +49,84 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       container = container_fixture(other_user) |       container = container_fixture(other_user) | ||||||
|       ammo_type = ammo_type_fixture(other_user) |       ammo_type = ammo_type_fixture(other_user) | ||||||
|       {1, [pack]} = pack_fixture(%{count: 25}, ammo_type, container, other_user) |       {1, [pack]} = pack_fixture(%{count: 25}, ammo_type, container, other_user) | ||||||
|       shot_group_fixture(%{count: 1, date: ~N[2022-02-13 03:17:00]}, other_user, pack) |       shot_record_fixture(%{count: 1, date: ~N[2022-02-13 03:17:00]}, other_user, pack) | ||||||
|       assert ActivityLog.get_shot_record_count!(other_user) == 1 |       assert ActivityLog.get_shot_record_count!(other_user) == 1 | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "get_shot_group!/2 returns the shot_group with given id", |     test "get_shot_record!/2 returns the shot_record with given id", | ||||||
|          %{shot_group: shot_group, current_user: current_user} do |          %{shot_record: shot_record, current_user: current_user} do | ||||||
|       assert ActivityLog.get_shot_group!(shot_group.id, current_user) == shot_group |       assert ActivityLog.get_shot_record!(shot_record.id, current_user) == shot_record | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "get_shot_group!/2 does not return a shot_group of another user", |     test "get_shot_record!/2 does not return a shot_record of another user", | ||||||
|          %{shot_group: shot_group} do |          %{shot_record: shot_record} do | ||||||
|       another_user = user_fixture() |       another_user = user_fixture() | ||||||
|  |  | ||||||
|       assert_raise Ecto.NoResultsError, fn -> |       assert_raise Ecto.NoResultsError, fn -> | ||||||
|         ActivityLog.get_shot_group!(shot_group.id, another_user) |         ActivityLog.get_shot_record!(shot_record.id, another_user) | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_shot_group/3 with valid data creates a shot_group", |     test "create_shot_record/3 with valid data creates a shot_record", | ||||||
|          %{current_user: current_user, pack: pack} do |          %{current_user: current_user, pack: pack} do | ||||||
|       valid_attrs = %{count: 10, date: ~D[2022-02-13], notes: "some notes"} |       valid_attrs = %{count: 10, date: ~D[2022-02-13], notes: "some notes"} | ||||||
|  |  | ||||||
|       assert {:ok, %ShotGroup{} = shot_group} = |       assert {:ok, %ShotRecord{} = shot_record} = | ||||||
|                ActivityLog.create_shot_group(valid_attrs, current_user, pack) |                ActivityLog.create_shot_record(valid_attrs, current_user, pack) | ||||||
|  |  | ||||||
|       assert shot_group.count == 10 |       assert shot_record.count == 10 | ||||||
|       assert shot_group.date == ~D[2022-02-13] |       assert shot_record.date == ~D[2022-02-13] | ||||||
|       assert shot_group.notes == "some notes" |       assert shot_record.notes == "some notes" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_shot_group/3 removes corresponding count from pack", |     test "create_shot_record/3 removes corresponding count from pack", | ||||||
|          %{ |          %{ | ||||||
|            current_user: current_user, |            current_user: current_user, | ||||||
|            pack: %{id: pack_id, count: org_count} = pack |            pack: %{id: pack_id, count: org_count} = pack | ||||||
|          } do |          } do | ||||||
|       valid_attrs = %{count: 10, date: ~D[2022-02-13], notes: "some notes"} |       valid_attrs = %{count: 10, date: ~D[2022-02-13], notes: "some notes"} | ||||||
|  |  | ||||||
|       assert {:ok, %ShotGroup{} = shot_group} = |       assert {:ok, %ShotRecord{} = shot_record} = | ||||||
|                ActivityLog.create_shot_group(valid_attrs, current_user, pack) |                ActivityLog.create_shot_record(valid_attrs, current_user, pack) | ||||||
|  |  | ||||||
|       %{count: new_count} = pack_id |> Ammo.get_pack!(current_user) |       %{count: new_count} = pack_id |> Ammo.get_pack!(current_user) | ||||||
|  |  | ||||||
|       assert org_count - shot_group.count == new_count |       assert org_count - shot_record.count == new_count | ||||||
|       assert new_count == 10 |       assert new_count == 10 | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_shot_group/3 does not remove more tha pack amount", |     test "create_shot_record/3 does not remove more tha pack amount", | ||||||
|          %{current_user: current_user, pack: %{id: pack_id} = pack} do |          %{current_user: current_user, pack: %{id: pack_id} = pack} do | ||||||
|       valid_attrs = %{count: 20, date: ~D[2022-02-13], notes: "some notes"} |       valid_attrs = %{count: 20, date: ~D[2022-02-13], notes: "some notes"} | ||||||
|  |  | ||||||
|       assert {:ok, %ShotGroup{}} = ActivityLog.create_shot_group(valid_attrs, current_user, pack) |       assert {:ok, %ShotRecord{}} = | ||||||
|  |                ActivityLog.create_shot_record(valid_attrs, current_user, pack) | ||||||
|  |  | ||||||
|       pack = pack_id |> Ammo.get_pack!(current_user) |       pack = pack_id |> Ammo.get_pack!(current_user) | ||||||
|  |  | ||||||
|       assert pack.count == 0 |       assert pack.count == 0 | ||||||
|  |  | ||||||
|       assert {:error, %Ecto.Changeset{}} = |       assert {:error, %Ecto.Changeset{}} = | ||||||
|                ActivityLog.create_shot_group(%{count: 1}, current_user, pack) |                ActivityLog.create_shot_record(%{count: 1}, current_user, pack) | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_shot_group/3 with invalid data returns error changeset", |     test "create_shot_record/3 with invalid data returns error changeset", | ||||||
|          %{current_user: current_user, pack: pack} do |          %{current_user: current_user, pack: pack} do | ||||||
|       invalid_params = %{count: nil, date: nil, notes: nil} |       invalid_params = %{count: nil, date: nil, notes: nil} | ||||||
|  |  | ||||||
|       assert {:error, %Ecto.Changeset{}} = |       assert {:error, %Ecto.Changeset{}} = | ||||||
|                ActivityLog.create_shot_group(invalid_params, current_user, pack) |                ActivityLog.create_shot_record(invalid_params, current_user, pack) | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "update_shot_group/3 with valid data updates the shot_group and pack", |     test "update_shot_record/3 with valid data updates the shot_record and pack", | ||||||
|          %{ |          %{ | ||||||
|            shot_group: shot_group, |            shot_record: shot_record, | ||||||
|            pack: %{id: pack_id}, |            pack: %{id: pack_id}, | ||||||
|            current_user: current_user |            current_user: current_user | ||||||
|          } do |          } do | ||||||
|       assert {:ok, %ShotGroup{} = shot_group} = |       assert {:ok, %ShotRecord{} = shot_record} = | ||||||
|                ActivityLog.update_shot_group( |                ActivityLog.update_shot_record( | ||||||
|                  shot_group, |                  shot_record, | ||||||
|                  %{ |                  %{ | ||||||
|                    count: 10, |                    count: 10, | ||||||
|                    date: ~D[2022-02-13], |                    date: ~D[2022-02-13], | ||||||
| @@ -136,14 +137,14 @@ defmodule Cannery.ActivityLogTest do | |||||||
|  |  | ||||||
|       pack = pack_id |> Ammo.get_pack!(current_user) |       pack = pack_id |> Ammo.get_pack!(current_user) | ||||||
|  |  | ||||||
|       assert shot_group.count == 10 |       assert shot_record.count == 10 | ||||||
|       assert pack.count == 15 |       assert pack.count == 15 | ||||||
|       assert shot_group.date == ~D[2022-02-13] |       assert shot_record.date == ~D[2022-02-13] | ||||||
|       assert shot_group.notes == "some updated notes" |       assert shot_record.notes == "some updated notes" | ||||||
|  |  | ||||||
|       assert {:ok, %ShotGroup{} = shot_group} = |       assert {:ok, %ShotRecord{} = shot_record} = | ||||||
|                ActivityLog.update_shot_group( |                ActivityLog.update_shot_record( | ||||||
|                  shot_group, |                  shot_record, | ||||||
|                  %{ |                  %{ | ||||||
|                    count: 25, |                    count: 25, | ||||||
|                    date: ~D[2022-02-13], |                    date: ~D[2022-02-13], | ||||||
| @@ -154,37 +155,37 @@ defmodule Cannery.ActivityLogTest do | |||||||
|  |  | ||||||
|       pack = pack_id |> Ammo.get_pack!(current_user) |       pack = pack_id |> Ammo.get_pack!(current_user) | ||||||
|  |  | ||||||
|       assert shot_group.count == 25 |       assert shot_record.count == 25 | ||||||
|       assert pack.count == 0 |       assert pack.count == 0 | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "update_shot_group/3 with invalid data returns error changeset", |     test "update_shot_record/3 with invalid data returns error changeset", | ||||||
|          %{shot_group: shot_group, current_user: current_user} do |          %{shot_record: shot_record, current_user: current_user} do | ||||||
|       assert {:error, %Ecto.Changeset{}} = |       assert {:error, %Ecto.Changeset{}} = | ||||||
|                ActivityLog.update_shot_group( |                ActivityLog.update_shot_record( | ||||||
|                  shot_group, |                  shot_record, | ||||||
|                  %{count: 26, date: nil, notes: nil}, |                  %{count: 26, date: nil, notes: nil}, | ||||||
|                  current_user |                  current_user | ||||||
|                ) |                ) | ||||||
|  |  | ||||||
|       assert {:error, %Ecto.Changeset{}} = |       assert {:error, %Ecto.Changeset{}} = | ||||||
|                ActivityLog.update_shot_group( |                ActivityLog.update_shot_record( | ||||||
|                  shot_group, |                  shot_record, | ||||||
|                  %{count: -1, date: nil, notes: nil}, |                  %{count: -1, date: nil, notes: nil}, | ||||||
|                  current_user |                  current_user | ||||||
|                ) |                ) | ||||||
|  |  | ||||||
|       assert shot_group == ActivityLog.get_shot_group!(shot_group.id, current_user) |       assert shot_record == ActivityLog.get_shot_record!(shot_record.id, current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "delete_shot_group/2 deletes the shot_group and adds value back", |     test "delete_shot_record/2 deletes the shot_record and adds value back", | ||||||
|          %{shot_group: shot_group, current_user: current_user, pack: %{id: pack_id}} do |          %{shot_record: shot_record, current_user: current_user, pack: %{id: pack_id}} do | ||||||
|       assert {:ok, %ShotGroup{}} = ActivityLog.delete_shot_group(shot_group, current_user) |       assert {:ok, %ShotRecord{}} = ActivityLog.delete_shot_record(shot_record, current_user) | ||||||
|  |  | ||||||
|       assert %{count: 25} = pack_id |> Ammo.get_pack!(current_user) |       assert %{count: 25} = pack_id |> Ammo.get_pack!(current_user) | ||||||
|  |  | ||||||
|       assert_raise Ecto.NoResultsError, fn -> |       assert_raise Ecto.NoResultsError, fn -> | ||||||
|         ActivityLog.get_shot_group!(shot_group.id, current_user) |         ActivityLog.get_shot_record!(shot_record.id, current_user) | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -198,10 +199,10 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       assert 0 = another_pack |> ActivityLog.get_used_count(current_user) |       assert 0 = another_pack |> ActivityLog.get_used_count(current_user) | ||||||
|       assert 5 = pack |> ActivityLog.get_used_count(current_user) |       assert 5 = pack |> ActivityLog.get_used_count(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 15}, current_user, pack) |       shot_record_fixture(%{count: 15}, current_user, pack) | ||||||
|       assert 20 = pack |> ActivityLog.get_used_count(current_user) |       assert 20 = pack |> ActivityLog.get_used_count(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 10}, current_user, pack) |       shot_record_fixture(%{count: 10}, current_user, pack) | ||||||
|       assert 30 = pack |> ActivityLog.get_used_count(current_user) |       assert 30 = pack |> ActivityLog.get_used_count(current_user) | ||||||
|  |  | ||||||
|       {1, [another_pack]} = pack_fixture(ammo_type, container, current_user) |       {1, [another_pack]} = pack_fixture(ammo_type, container, current_user) | ||||||
| @@ -220,17 +221,17 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       assert %{pack_id => 5} == |       assert %{pack_id => 5} == | ||||||
|                [pack, another_pack] |> ActivityLog.get_used_counts(current_user) |                [pack, another_pack] |> ActivityLog.get_used_counts(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 5}, current_user, another_pack) |       shot_record_fixture(%{count: 5}, current_user, another_pack) | ||||||
|       used_counts = [pack, another_pack] |> ActivityLog.get_used_counts(current_user) |       used_counts = [pack, another_pack] |> ActivityLog.get_used_counts(current_user) | ||||||
|       assert %{^pack_id => 5} = used_counts |       assert %{^pack_id => 5} = used_counts | ||||||
|       assert %{^another_pack_id => 5} = used_counts |       assert %{^another_pack_id => 5} = used_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 15}, current_user, pack) |       shot_record_fixture(%{count: 15}, current_user, pack) | ||||||
|       used_counts = [pack, another_pack] |> ActivityLog.get_used_counts(current_user) |       used_counts = [pack, another_pack] |> ActivityLog.get_used_counts(current_user) | ||||||
|       assert %{^pack_id => 20} = used_counts |       assert %{^pack_id => 20} = used_counts | ||||||
|       assert %{^another_pack_id => 5} = used_counts |       assert %{^another_pack_id => 5} = used_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 10}, current_user, pack) |       shot_record_fixture(%{count: 10}, current_user, pack) | ||||||
|       used_counts = [pack, another_pack] |> ActivityLog.get_used_counts(current_user) |       used_counts = [pack, another_pack] |> ActivityLog.get_used_counts(current_user) | ||||||
|       assert %{^pack_id => 30} = used_counts |       assert %{^pack_id => 30} = used_counts | ||||||
|       assert %{^another_pack_id => 5} = used_counts |       assert %{^another_pack_id => 5} = used_counts | ||||||
| @@ -240,17 +241,17 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       pack: pack, |       pack: pack, | ||||||
|       ammo_type: ammo_type, |       ammo_type: ammo_type, | ||||||
|       container: container, |       container: container, | ||||||
|       shot_group: %{date: date}, |       shot_record: %{date: date}, | ||||||
|       current_user: current_user |       current_user: current_user | ||||||
|     } do |     } do | ||||||
|       {1, [another_pack]} = pack_fixture(ammo_type, container, current_user) |       {1, [another_pack]} = pack_fixture(ammo_type, container, current_user) | ||||||
|       assert another_pack |> ActivityLog.get_last_used_date(current_user) |> is_nil() |       assert another_pack |> ActivityLog.get_last_used_date(current_user) |> is_nil() | ||||||
|       assert ^date = pack |> ActivityLog.get_last_used_date(current_user) |       assert ^date = pack |> ActivityLog.get_last_used_date(current_user) | ||||||
|  |  | ||||||
|       %{date: date} = shot_group_fixture(%{date: ~D[2022-11-10]}, current_user, pack) |       %{date: date} = shot_record_fixture(%{date: ~D[2022-11-10]}, current_user, pack) | ||||||
|       assert ^date = pack |> ActivityLog.get_last_used_date(current_user) |       assert ^date = pack |> ActivityLog.get_last_used_date(current_user) | ||||||
|  |  | ||||||
|       %{date: date} = shot_group_fixture(%{date: ~D[2022-11-11]}, current_user, pack) |       %{date: date} = shot_record_fixture(%{date: ~D[2022-11-11]}, current_user, pack) | ||||||
|       assert ^date = pack |> ActivityLog.get_last_used_date(current_user) |       assert ^date = pack |> ActivityLog.get_last_used_date(current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -258,7 +259,7 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       pack: %{id: pack_id} = pack, |       pack: %{id: pack_id} = pack, | ||||||
|       ammo_type: ammo_type, |       ammo_type: ammo_type, | ||||||
|       container: container, |       container: container, | ||||||
|       shot_group: %{date: date}, |       shot_record: %{date: date}, | ||||||
|       current_user: current_user |       current_user: current_user | ||||||
|     } do |     } do | ||||||
|       {1, [%{id: another_pack_id} = another_pack]} = |       {1, [%{id: another_pack_id} = another_pack]} = | ||||||
| @@ -268,32 +269,32 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       assert %{pack_id => date} == |       assert %{pack_id => date} == | ||||||
|                [pack, another_pack] |> ActivityLog.get_last_used_dates(current_user) |                [pack, another_pack] |> ActivityLog.get_last_used_dates(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{date: ~D[2022-11-09]}, current_user, another_pack) |       shot_record_fixture(%{date: ~D[2022-11-09]}, current_user, another_pack) | ||||||
|  |  | ||||||
|       # setting initial date |       # setting initial date | ||||||
|       last_used_shot_groups = |       last_used_shot_records = | ||||||
|         [pack, another_pack] |> ActivityLog.get_last_used_dates(current_user) |         [pack, another_pack] |> ActivityLog.get_last_used_dates(current_user) | ||||||
|  |  | ||||||
|       assert %{^pack_id => ^date} = last_used_shot_groups |       assert %{^pack_id => ^date} = last_used_shot_records | ||||||
|       assert %{^another_pack_id => ~D[2022-11-09]} = last_used_shot_groups |       assert %{^another_pack_id => ~D[2022-11-09]} = last_used_shot_records | ||||||
|  |  | ||||||
|       # setting another date |       # setting another date | ||||||
|       shot_group_fixture(%{date: ~D[2022-11-10]}, current_user, pack) |       shot_record_fixture(%{date: ~D[2022-11-10]}, current_user, pack) | ||||||
|  |  | ||||||
|       last_used_shot_groups = |       last_used_shot_records = | ||||||
|         [pack, another_pack] |> ActivityLog.get_last_used_dates(current_user) |         [pack, another_pack] |> ActivityLog.get_last_used_dates(current_user) | ||||||
|  |  | ||||||
|       assert %{^pack_id => ~D[2022-11-10]} = last_used_shot_groups |       assert %{^pack_id => ~D[2022-11-10]} = last_used_shot_records | ||||||
|       assert %{^another_pack_id => ~D[2022-11-09]} = last_used_shot_groups |       assert %{^another_pack_id => ~D[2022-11-09]} = last_used_shot_records | ||||||
|  |  | ||||||
|       # setting yet another date |       # setting yet another date | ||||||
|       shot_group_fixture(%{date: ~D[2022-11-11]}, current_user, pack) |       shot_record_fixture(%{date: ~D[2022-11-11]}, current_user, pack) | ||||||
|  |  | ||||||
|       last_used_shot_groups = |       last_used_shot_records = | ||||||
|         [pack, another_pack] |> ActivityLog.get_last_used_dates(current_user) |         [pack, another_pack] |> ActivityLog.get_last_used_dates(current_user) | ||||||
|  |  | ||||||
|       assert %{^pack_id => ~D[2022-11-11]} = last_used_shot_groups |       assert %{^pack_id => ~D[2022-11-11]} = last_used_shot_records | ||||||
|       assert %{^another_pack_id => ~D[2022-11-09]} = last_used_shot_groups |       assert %{^another_pack_id => ~D[2022-11-09]} = last_used_shot_records | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "get_used_count_for_ammo_type/2 gets accurate used round count for ammo type", |     test "get_used_count_for_ammo_type/2 gets accurate used round count for ammo type", | ||||||
| @@ -302,10 +303,10 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       assert 0 = another_ammo_type |> ActivityLog.get_used_count_for_ammo_type(current_user) |       assert 0 = another_ammo_type |> ActivityLog.get_used_count_for_ammo_type(current_user) | ||||||
|       assert 5 = ammo_type |> ActivityLog.get_used_count_for_ammo_type(current_user) |       assert 5 = ammo_type |> ActivityLog.get_used_count_for_ammo_type(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 5}, current_user, pack) |       shot_record_fixture(%{count: 5}, current_user, pack) | ||||||
|       assert 10 = ammo_type |> ActivityLog.get_used_count_for_ammo_type(current_user) |       assert 10 = ammo_type |> ActivityLog.get_used_count_for_ammo_type(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1}, current_user, pack) |       shot_record_fixture(%{count: 1}, current_user, pack) | ||||||
|       assert 11 = ammo_type |> ActivityLog.get_used_count_for_ammo_type(current_user) |       assert 11 = ammo_type |> ActivityLog.get_used_count_for_ammo_type(current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -323,7 +324,7 @@ defmodule Cannery.ActivityLogTest do | |||||||
|                |> ActivityLog.get_used_count_for_ammo_types(current_user) |                |> ActivityLog.get_used_count_for_ammo_types(current_user) | ||||||
|  |  | ||||||
|       # use generated pack |       # use generated pack | ||||||
|       shot_group_fixture(%{count: 5}, current_user, pack) |       shot_record_fixture(%{count: 5}, current_user, pack) | ||||||
|  |  | ||||||
|       used_counts = |       used_counts = | ||||||
|         [ammo_type, another_ammo_type] |> ActivityLog.get_used_count_for_ammo_types(current_user) |         [ammo_type, another_ammo_type] |> ActivityLog.get_used_count_for_ammo_types(current_user) | ||||||
| @@ -332,7 +333,7 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       assert %{^another_ammo_type_id => 5} = used_counts |       assert %{^another_ammo_type_id => 5} = used_counts | ||||||
|  |  | ||||||
|       # use generated pack again |       # use generated pack again | ||||||
|       shot_group_fixture(%{count: 1}, current_user, pack) |       shot_record_fixture(%{count: 1}, current_user, pack) | ||||||
|  |  | ||||||
|       used_counts = |       used_counts = | ||||||
|         [ammo_type, another_ammo_type] |> ActivityLog.get_used_count_for_ammo_types(current_user) |         [ammo_type, another_ammo_type] |> ActivityLog.get_used_count_for_ammo_types(current_user) | ||||||
| @@ -342,7 +343,7 @@ defmodule Cannery.ActivityLogTest do | |||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   describe "list_shot_groups/3" do |   describe "list_shot_records/3" do | ||||||
|     setup do |     setup do | ||||||
|       current_user = user_fixture() |       current_user = user_fixture() | ||||||
|       container = container_fixture(current_user) |       container = container_fixture(current_user) | ||||||
| @@ -357,7 +358,7 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       ] |       ] | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "list_shot_groups/3 returns relevant shot_groups for a type", |     test "list_shot_records/3 returns relevant shot_records for a type", | ||||||
|          %{current_user: current_user, container: container} do |          %{current_user: current_user, container: container} do | ||||||
|       other_user = user_fixture() |       other_user = user_fixture() | ||||||
|       other_container = container_fixture(other_user) |       other_container = container_fixture(other_user) | ||||||
| @@ -365,56 +366,56 @@ defmodule Cannery.ActivityLogTest do | |||||||
|       for class <- ["rifle", "shotgun", "pistol"] do |       for class <- ["rifle", "shotgun", "pistol"] do | ||||||
|         other_ammo_type = ammo_type_fixture(%{class: class}, other_user) |         other_ammo_type = ammo_type_fixture(%{class: class}, other_user) | ||||||
|         {1, [other_pack]} = pack_fixture(other_ammo_type, other_container, other_user) |         {1, [other_pack]} = pack_fixture(other_ammo_type, other_container, other_user) | ||||||
|         shot_group_fixture(other_user, other_pack) |         shot_record_fixture(other_user, other_pack) | ||||||
|       end |       end | ||||||
|  |  | ||||||
|       rifle_ammo_type = ammo_type_fixture(%{class: :rifle}, current_user) |       rifle_ammo_type = ammo_type_fixture(%{class: :rifle}, current_user) | ||||||
|       {1, [rifle_pack]} = pack_fixture(rifle_ammo_type, container, current_user) |       {1, [rifle_pack]} = pack_fixture(rifle_ammo_type, container, current_user) | ||||||
|       rifle_shot_group = shot_group_fixture(current_user, rifle_pack) |       rifle_shot_record = shot_record_fixture(current_user, rifle_pack) | ||||||
|  |  | ||||||
|       shotgun_ammo_type = ammo_type_fixture(%{class: :shotgun}, current_user) |       shotgun_ammo_type = ammo_type_fixture(%{class: :shotgun}, current_user) | ||||||
|       {1, [shotgun_pack]} = pack_fixture(shotgun_ammo_type, container, current_user) |       {1, [shotgun_pack]} = pack_fixture(shotgun_ammo_type, container, current_user) | ||||||
|       shotgun_shot_group = shot_group_fixture(current_user, shotgun_pack) |       shotgun_shot_record = shot_record_fixture(current_user, shotgun_pack) | ||||||
|  |  | ||||||
|       pistol_ammo_type = ammo_type_fixture(%{class: :pistol}, current_user) |       pistol_ammo_type = ammo_type_fixture(%{class: :pistol}, current_user) | ||||||
|       {1, [pistol_pack]} = pack_fixture(pistol_ammo_type, container, current_user) |       {1, [pistol_pack]} = pack_fixture(pistol_ammo_type, container, current_user) | ||||||
|       pistol_shot_group = shot_group_fixture(current_user, pistol_pack) |       pistol_shot_record = shot_record_fixture(current_user, pistol_pack) | ||||||
|  |  | ||||||
|       assert [^rifle_shot_group] = ActivityLog.list_shot_groups(:rifle, current_user) |       assert [^rifle_shot_record] = ActivityLog.list_shot_records(:rifle, current_user) | ||||||
|       assert [^shotgun_shot_group] = ActivityLog.list_shot_groups(:shotgun, current_user) |       assert [^shotgun_shot_record] = ActivityLog.list_shot_records(:shotgun, current_user) | ||||||
|       assert [^pistol_shot_group] = ActivityLog.list_shot_groups(:pistol, current_user) |       assert [^pistol_shot_record] = ActivityLog.list_shot_records(:pistol, current_user) | ||||||
|  |  | ||||||
|       shot_groups = ActivityLog.list_shot_groups(:all, current_user) |       shot_records = ActivityLog.list_shot_records(:all, current_user) | ||||||
|       assert Enum.count(shot_groups) == 3 |       assert Enum.count(shot_records) == 3 | ||||||
|       assert rifle_shot_group in shot_groups |       assert rifle_shot_record in shot_records | ||||||
|       assert shotgun_shot_group in shot_groups |       assert shotgun_shot_record in shot_records | ||||||
|       assert pistol_shot_group in shot_groups |       assert pistol_shot_record in shot_records | ||||||
|  |  | ||||||
|       shot_groups = ActivityLog.list_shot_groups(nil, current_user) |       shot_records = ActivityLog.list_shot_records(nil, current_user) | ||||||
|       assert Enum.count(shot_groups) == 3 |       assert Enum.count(shot_records) == 3 | ||||||
|       assert rifle_shot_group in shot_groups |       assert rifle_shot_record in shot_records | ||||||
|       assert shotgun_shot_group in shot_groups |       assert shotgun_shot_record in shot_records | ||||||
|       assert pistol_shot_group in shot_groups |       assert pistol_shot_record in shot_records | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "list_shot_groups/3 returns relevant shot_groups for a search", %{ |     test "list_shot_records/3 returns relevant shot_records for a search", %{ | ||||||
|       ammo_type: ammo_type, |       ammo_type: ammo_type, | ||||||
|       pack: pack, |       pack: pack, | ||||||
|       container: container, |       container: container, | ||||||
|       current_user: current_user |       current_user: current_user | ||||||
|     } do |     } do | ||||||
|       shot_group_a = shot_group_fixture(%{notes: "amazing"}, current_user, pack) |       shot_record_a = shot_record_fixture(%{notes: "amazing"}, current_user, pack) | ||||||
|  |  | ||||||
|       {1, [another_pack]} = |       {1, [another_pack]} = | ||||||
|         pack_fixture(%{notes: "stupendous"}, ammo_type, container, current_user) |         pack_fixture(%{notes: "stupendous"}, ammo_type, container, current_user) | ||||||
|  |  | ||||||
|       shot_group_b = shot_group_fixture(current_user, another_pack) |       shot_record_b = shot_record_fixture(current_user, another_pack) | ||||||
|  |  | ||||||
|       another_ammo_type = ammo_type_fixture(%{name: "fabulous ammo"}, current_user) |       another_ammo_type = ammo_type_fixture(%{name: "fabulous ammo"}, current_user) | ||||||
|  |  | ||||||
|       {1, [yet_another_pack]} = pack_fixture(another_ammo_type, container, current_user) |       {1, [yet_another_pack]} = pack_fixture(another_ammo_type, container, current_user) | ||||||
|  |  | ||||||
|       shot_group_c = shot_group_fixture(current_user, yet_another_pack) |       shot_record_c = shot_record_fixture(current_user, yet_another_pack) | ||||||
|  |  | ||||||
|       another_user = user_fixture() |       another_user = user_fixture() | ||||||
|       another_container = container_fixture(another_user) |       another_container = container_fixture(another_user) | ||||||
| @@ -422,16 +423,16 @@ defmodule Cannery.ActivityLogTest do | |||||||
|  |  | ||||||
|       {1, [another_pack]} = pack_fixture(another_ammo_type, another_container, another_user) |       {1, [another_pack]} = pack_fixture(another_ammo_type, another_container, another_user) | ||||||
|  |  | ||||||
|       _shouldnt_return = shot_group_fixture(another_user, another_pack) |       _shouldnt_return = shot_record_fixture(another_user, another_pack) | ||||||
|  |  | ||||||
|       # notes |       # notes | ||||||
|       assert ActivityLog.list_shot_groups("amazing", :all, current_user) == [shot_group_a] |       assert ActivityLog.list_shot_records("amazing", :all, current_user) == [shot_record_a] | ||||||
|  |  | ||||||
|       # pack attributes |       # pack attributes | ||||||
|       assert ActivityLog.list_shot_groups("stupendous", :all, current_user) == [shot_group_b] |       assert ActivityLog.list_shot_records("stupendous", :all, current_user) == [shot_record_b] | ||||||
|  |  | ||||||
|       # ammo type attributes |       # ammo type attributes | ||||||
|       assert ActivityLog.list_shot_groups("fabulous", :all, current_user) == [shot_group_c] |       assert ActivityLog.list_shot_records("fabulous", :all, current_user) == [shot_record_c] | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|   | |||||||
| @@ -362,10 +362,10 @@ defmodule Cannery.AmmoTest do | |||||||
|  |  | ||||||
|       assert 51 = Ammo.get_round_count_for_ammo_type(ammo_type, current_user) |       assert 51 = Ammo.get_round_count_for_ammo_type(ammo_type, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 26}, current_user, pack) |       shot_record_fixture(%{count: 26}, current_user, pack) | ||||||
|       assert 25 = Ammo.get_round_count_for_ammo_type(ammo_type, current_user) |       assert 25 = Ammo.get_round_count_for_ammo_type(ammo_type, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1}, current_user, first_pack) |       shot_record_fixture(%{count: 1}, current_user, first_pack) | ||||||
|       assert 24 = Ammo.get_round_count_for_ammo_type(ammo_type, current_user) |       assert 24 = Ammo.get_round_count_for_ammo_type(ammo_type, current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -397,7 +397,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^ammo_type_id => 51} = round_counts |       assert %{^ammo_type_id => 51} = round_counts | ||||||
|       assert %{^another_ammo_type_id => 1} = round_counts |       assert %{^another_ammo_type_id => 1} = round_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 26}, current_user, pack) |       shot_record_fixture(%{count: 26}, current_user, pack) | ||||||
|  |  | ||||||
|       round_counts = |       round_counts = | ||||||
|         [ammo_type, another_ammo_type] |> Ammo.get_round_count_for_ammo_types(current_user) |         [ammo_type, another_ammo_type] |> Ammo.get_round_count_for_ammo_types(current_user) | ||||||
| @@ -405,7 +405,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^ammo_type_id => 25} = round_counts |       assert %{^ammo_type_id => 25} = round_counts | ||||||
|       assert %{^another_ammo_type_id => 1} = round_counts |       assert %{^another_ammo_type_id => 1} = round_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1}, current_user, first_pack) |       shot_record_fixture(%{count: 1}, current_user, first_pack) | ||||||
|  |  | ||||||
|       round_counts = |       round_counts = | ||||||
|         [ammo_type, another_ammo_type] |> Ammo.get_round_count_for_ammo_types(current_user) |         [ammo_type, another_ammo_type] |> Ammo.get_round_count_for_ammo_types(current_user) | ||||||
| @@ -426,10 +426,10 @@ defmodule Cannery.AmmoTest do | |||||||
|  |  | ||||||
|       assert 51 = Ammo.get_historical_count_for_ammo_type(ammo_type, current_user) |       assert 51 = Ammo.get_historical_count_for_ammo_type(ammo_type, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 26}, current_user, pack) |       shot_record_fixture(%{count: 26}, current_user, pack) | ||||||
|       assert 51 = Ammo.get_historical_count_for_ammo_type(ammo_type, current_user) |       assert 51 = Ammo.get_historical_count_for_ammo_type(ammo_type, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1}, current_user, first_pack) |       shot_record_fixture(%{count: 1}, current_user, first_pack) | ||||||
|       assert 51 = Ammo.get_historical_count_for_ammo_type(ammo_type, current_user) |       assert 51 = Ammo.get_historical_count_for_ammo_type(ammo_type, current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -464,7 +464,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^ammo_type_id => 51} = historical_counts |       assert %{^ammo_type_id => 51} = historical_counts | ||||||
|       assert %{^another_ammo_type_id => 1} = historical_counts |       assert %{^another_ammo_type_id => 1} = historical_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 26}, current_user, pack) |       shot_record_fixture(%{count: 26}, current_user, pack) | ||||||
|  |  | ||||||
|       historical_counts = |       historical_counts = | ||||||
|         [ammo_type, another_ammo_type] |> Ammo.get_historical_count_for_ammo_types(current_user) |         [ammo_type, another_ammo_type] |> Ammo.get_historical_count_for_ammo_types(current_user) | ||||||
| @@ -472,7 +472,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^ammo_type_id => 51} = historical_counts |       assert %{^ammo_type_id => 51} = historical_counts | ||||||
|       assert %{^another_ammo_type_id => 1} = historical_counts |       assert %{^another_ammo_type_id => 1} = historical_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1}, current_user, first_pack) |       shot_record_fixture(%{count: 1}, current_user, first_pack) | ||||||
|  |  | ||||||
|       historical_counts = |       historical_counts = | ||||||
|         [ammo_type, another_ammo_type] |> Ammo.get_historical_count_for_ammo_types(current_user) |         [ammo_type, another_ammo_type] |> Ammo.get_historical_count_for_ammo_types(current_user) | ||||||
| @@ -493,10 +493,10 @@ defmodule Cannery.AmmoTest do | |||||||
|  |  | ||||||
|       assert 0 = Ammo.get_used_packs_count_for_type(ammo_type, current_user) |       assert 0 = Ammo.get_used_packs_count_for_type(ammo_type, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 50}, current_user, pack) |       shot_record_fixture(%{count: 50}, current_user, pack) | ||||||
|       assert 1 = Ammo.get_used_packs_count_for_type(ammo_type, current_user) |       assert 1 = Ammo.get_used_packs_count_for_type(ammo_type, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1}, current_user, first_pack) |       shot_record_fixture(%{count: 1}, current_user, first_pack) | ||||||
|       assert 2 = Ammo.get_used_packs_count_for_type(ammo_type, current_user) |       assert 2 = Ammo.get_used_packs_count_for_type(ammo_type, current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -526,7 +526,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       # testing ammo type with used pack |       # testing ammo type with used pack | ||||||
|       {1, [another_pack]} = pack_fixture(%{count: 50}, another_ammo_type, container, current_user) |       {1, [another_pack]} = pack_fixture(%{count: 50}, another_ammo_type, container, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 50}, current_user, another_pack) |       shot_record_fixture(%{count: 50}, current_user, another_pack) | ||||||
|  |  | ||||||
|       assert %{another_ammo_type_id => 1} == |       assert %{another_ammo_type_id => 1} == | ||||||
|                [ammo_type, another_ammo_type] |                [ammo_type, another_ammo_type] | ||||||
| @@ -534,7 +534,7 @@ defmodule Cannery.AmmoTest do | |||||||
|  |  | ||||||
|       # testing two ammo types with zero and one used packs |       # testing two ammo types with zero and one used packs | ||||||
|       {1, [pack]} = pack_fixture(%{count: 50}, ammo_type, container, current_user) |       {1, [pack]} = pack_fixture(%{count: 50}, ammo_type, container, current_user) | ||||||
|       shot_group_fixture(%{count: 50}, current_user, pack) |       shot_record_fixture(%{count: 50}, current_user, pack) | ||||||
|  |  | ||||||
|       used_counts = |       used_counts = | ||||||
|         [ammo_type, another_ammo_type] |> Ammo.get_used_packs_count_for_types(current_user) |         [ammo_type, another_ammo_type] |> Ammo.get_used_packs_count_for_types(current_user) | ||||||
| @@ -543,7 +543,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^another_ammo_type_id => 1} = used_counts |       assert %{^another_ammo_type_id => 1} = used_counts | ||||||
|  |  | ||||||
|       # testing two ammo type with one and two used packs |       # testing two ammo type with one and two used packs | ||||||
|       shot_group_fixture(%{count: 1}, current_user, first_pack) |       shot_record_fixture(%{count: 1}, current_user, first_pack) | ||||||
|  |  | ||||||
|       used_counts = |       used_counts = | ||||||
|         [ammo_type, another_ammo_type] |> Ammo.get_used_packs_count_for_types(current_user) |         [ammo_type, another_ammo_type] |> Ammo.get_used_packs_count_for_types(current_user) | ||||||
| @@ -562,10 +562,10 @@ defmodule Cannery.AmmoTest do | |||||||
|  |  | ||||||
|       assert 26 = Ammo.get_packs_count_for_container!(container, current_user) |       assert 26 = Ammo.get_packs_count_for_container!(container, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1}, current_user, first_pack) |       shot_record_fixture(%{count: 1}, current_user, first_pack) | ||||||
|       assert 26 = Ammo.get_packs_count_for_container!(container, current_user) |       assert 26 = Ammo.get_packs_count_for_container!(container, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 4}, current_user, first_pack) |       shot_record_fixture(%{count: 4}, current_user, first_pack) | ||||||
|       assert 25 = Ammo.get_packs_count_for_container!(container, current_user) |       assert 25 = Ammo.get_packs_count_for_container!(container, current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -596,7 +596,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^container_id => 26} = packs_count |       assert %{^container_id => 26} = packs_count | ||||||
|       assert %{^another_container_id => 1} = packs_count |       assert %{^another_container_id => 1} = packs_count | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 1}, current_user, first_pack) |       shot_record_fixture(%{count: 1}, current_user, first_pack) | ||||||
|  |  | ||||||
|       packs_count = |       packs_count = | ||||||
|         [container, another_container] |         [container, another_container] | ||||||
| @@ -605,7 +605,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^container_id => 26} = packs_count |       assert %{^container_id => 26} = packs_count | ||||||
|       assert %{^another_container_id => 1} = packs_count |       assert %{^another_container_id => 1} = packs_count | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 4}, current_user, first_pack) |       shot_record_fixture(%{count: 4}, current_user, first_pack) | ||||||
|  |  | ||||||
|       packs_count = |       packs_count = | ||||||
|         [container, another_container] |         [container, another_container] | ||||||
| @@ -625,7 +625,7 @@ defmodule Cannery.AmmoTest do | |||||||
|  |  | ||||||
|       assert 130 = Ammo.get_round_count_for_container!(container, current_user) |       assert 130 = Ammo.get_round_count_for_container!(container, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 5}, current_user, first_pack) |       shot_record_fixture(%{count: 5}, current_user, first_pack) | ||||||
|       assert 125 = Ammo.get_round_count_for_container!(container, current_user) |       assert 125 = Ammo.get_round_count_for_container!(container, current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -655,7 +655,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^container_id => 130} = round_counts |       assert %{^container_id => 130} = round_counts | ||||||
|       assert %{^another_container_id => 5} = round_counts |       assert %{^another_container_id => 5} = round_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 5}, current_user, first_pack) |       shot_record_fixture(%{count: 5}, current_user, first_pack) | ||||||
|  |  | ||||||
|       round_counts = |       round_counts = | ||||||
|         [container, another_container] |> Ammo.get_round_count_for_containers(current_user) |         [container, another_container] |> Ammo.get_round_count_for_containers(current_user) | ||||||
| @@ -725,7 +725,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       {1, [another_pack]} = |       {1, [another_pack]} = | ||||||
|         pack_fixture(%{count: 30}, other_ammo_type, other_container, other_user) |         pack_fixture(%{count: 30}, other_ammo_type, other_container, other_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 30}, other_user, another_pack) |       shot_record_fixture(%{count: 30}, other_user, another_pack) | ||||||
|       assert Ammo.get_packs_count!(other_user) == 0 |       assert Ammo.get_packs_count!(other_user) == 0 | ||||||
|       assert Ammo.get_packs_count!(other_user, true) == 1 |       assert Ammo.get_packs_count!(other_user, true) == 1 | ||||||
|     end |     end | ||||||
| @@ -767,7 +767,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       {1, [%{id: another_pack_id} = another_pack]} = |       {1, [%{id: another_pack_id} = another_pack]} = | ||||||
|         pack_fixture(%{count: 30}, ammo_type, container, current_user) |         pack_fixture(%{count: 30}, ammo_type, container, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 30}, current_user, another_pack) |       shot_record_fixture(%{count: 30}, current_user, another_pack) | ||||||
|       another_pack = Ammo.get_pack!(another_pack_id, current_user) |       another_pack = Ammo.get_pack!(another_pack_id, current_user) | ||||||
|  |  | ||||||
|       assert Ammo.list_packs(nil, :all, current_user, false) == [pack] |       assert Ammo.list_packs(nil, :all, current_user, false) == [pack] | ||||||
| @@ -831,7 +831,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       {1, [pack]} = pack_fixture(ammo_type, container, current_user) |       {1, [pack]} = pack_fixture(ammo_type, container, current_user) | ||||||
|       assert [^pack] = Ammo.list_packs_for_type(ammo_type, current_user) |       assert [^pack] = Ammo.list_packs_for_type(ammo_type, current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(current_user, pack) |       shot_record_fixture(current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack.id, current_user) |       pack = Ammo.get_pack!(pack.id, current_user) | ||||||
|       assert [] == Ammo.list_packs_for_type(ammo_type, current_user) |       assert [] == Ammo.list_packs_for_type(ammo_type, current_user) | ||||||
|       assert [^pack] = Ammo.list_packs_for_type(ammo_type, current_user, true) |       assert [^pack] = Ammo.list_packs_for_type(ammo_type, current_user, true) | ||||||
| @@ -1013,15 +1013,15 @@ defmodule Cannery.AmmoTest do | |||||||
|          %{pack: %{id: pack_id} = pack, current_user: current_user} do |          %{pack: %{id: pack_id} = pack, current_user: current_user} do | ||||||
|       assert 100 = pack |> Ammo.get_percentage_remaining(current_user) |       assert 100 = pack |> Ammo.get_percentage_remaining(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 14}, current_user, pack) |       shot_record_fixture(%{count: 14}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|       assert 72 = pack |> Ammo.get_percentage_remaining(current_user) |       assert 72 = pack |> Ammo.get_percentage_remaining(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 11}, current_user, pack) |       shot_record_fixture(%{count: 11}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|       assert 50 = pack |> Ammo.get_percentage_remaining(current_user) |       assert 50 = pack |> Ammo.get_percentage_remaining(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 25}, current_user, pack) |       shot_record_fixture(%{count: 25}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|       assert 0 = pack |> Ammo.get_percentage_remaining(current_user) |       assert 0 = pack |> Ammo.get_percentage_remaining(current_user) | ||||||
|     end |     end | ||||||
| @@ -1044,7 +1044,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^pack_id => 100} = percentages |       assert %{^pack_id => 100} = percentages | ||||||
|       assert %{^another_pack_id => 100} = percentages |       assert %{^another_pack_id => 100} = percentages | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 14}, current_user, pack) |       shot_record_fixture(%{count: 14}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|  |  | ||||||
|       percentages = [pack, another_pack] |> Ammo.get_percentages_remaining(current_user) |       percentages = [pack, another_pack] |> Ammo.get_percentages_remaining(current_user) | ||||||
| @@ -1052,7 +1052,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^pack_id => 72} = percentages |       assert %{^pack_id => 72} = percentages | ||||||
|       assert %{^another_pack_id => 100} = percentages |       assert %{^another_pack_id => 100} = percentages | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 11}, current_user, pack) |       shot_record_fixture(%{count: 11}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|  |  | ||||||
|       percentages = [pack, another_pack] |> Ammo.get_percentages_remaining(current_user) |       percentages = [pack, another_pack] |> Ammo.get_percentages_remaining(current_user) | ||||||
| @@ -1060,7 +1060,7 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^pack_id => 50} = percentages |       assert %{^pack_id => 50} = percentages | ||||||
|       assert %{^another_pack_id => 100} = percentages |       assert %{^another_pack_id => 100} = percentages | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 25}, current_user, pack) |       shot_record_fixture(%{count: 25}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|  |  | ||||||
|       percentages = [pack, another_pack] |> Ammo.get_percentages_remaining(current_user) |       percentages = [pack, another_pack] |> Ammo.get_percentages_remaining(current_user) | ||||||
| @@ -1104,8 +1104,8 @@ defmodule Cannery.AmmoTest do | |||||||
|  |  | ||||||
|       assert 0.722 = pack |> Ammo.get_cpr(current_user) |       assert 0.722 = pack |> Ammo.get_cpr(current_user) | ||||||
|  |  | ||||||
|       # with shot group, maintains total |       # with shot record, maintains total | ||||||
|       shot_group_fixture(%{count: 14}, current_user, pack) |       shot_record_fixture(%{count: 14}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack.id, current_user) |       pack = Ammo.get_pack!(pack.id, current_user) | ||||||
|       assert 0.722 = pack |> Ammo.get_cpr(current_user) |       assert 0.722 = pack |> Ammo.get_cpr(current_user) | ||||||
|     end |     end | ||||||
| @@ -1151,8 +1151,8 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^another_pack_id => 1.5} = cprs |       assert %{^another_pack_id => 1.5} = cprs | ||||||
|       assert %{^yet_another_pack_id => 0.722} = cprs |       assert %{^yet_another_pack_id => 0.722} = cprs | ||||||
|  |  | ||||||
|       # with shot group, maintains total |       # with shot record, maintains total | ||||||
|       shot_group_fixture(%{count: 14}, current_user, yet_another_pack) |       shot_record_fixture(%{count: 14}, current_user, yet_another_pack) | ||||||
|       yet_another_pack = Ammo.get_pack!(yet_another_pack.id, current_user) |       yet_another_pack = Ammo.get_pack!(yet_another_pack.id, current_user) | ||||||
|  |  | ||||||
|       cprs = [pack, another_pack, yet_another_pack] |> Ammo.get_cprs(current_user) |       cprs = [pack, another_pack, yet_another_pack] |> Ammo.get_cprs(current_user) | ||||||
| @@ -1166,15 +1166,15 @@ defmodule Cannery.AmmoTest do | |||||||
|          %{pack: %{id: pack_id} = pack, current_user: current_user} do |          %{pack: %{id: pack_id} = pack, current_user: current_user} do | ||||||
|       assert 50 = pack |> Ammo.get_original_count(current_user) |       assert 50 = pack |> Ammo.get_original_count(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 14}, current_user, pack) |       shot_record_fixture(%{count: 14}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|       assert 50 = pack |> Ammo.get_original_count(current_user) |       assert 50 = pack |> Ammo.get_original_count(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 11}, current_user, pack) |       shot_record_fixture(%{count: 11}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|       assert 50 = pack |> Ammo.get_original_count(current_user) |       assert 50 = pack |> Ammo.get_original_count(current_user) | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 25}, current_user, pack) |       shot_record_fixture(%{count: 25}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|       assert 50 = pack |> Ammo.get_original_count(current_user) |       assert 50 = pack |> Ammo.get_original_count(current_user) | ||||||
|     end |     end | ||||||
| @@ -1192,19 +1192,19 @@ defmodule Cannery.AmmoTest do | |||||||
|       assert %{^pack_id => 50} = original_counts |       assert %{^pack_id => 50} = original_counts | ||||||
|       assert %{^another_pack_id => 25} = original_counts |       assert %{^another_pack_id => 25} = original_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 14}, current_user, pack) |       shot_record_fixture(%{count: 14}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|       original_counts = [pack, another_pack] |> Ammo.get_original_counts(current_user) |       original_counts = [pack, another_pack] |> Ammo.get_original_counts(current_user) | ||||||
|       assert %{^pack_id => 50} = original_counts |       assert %{^pack_id => 50} = original_counts | ||||||
|       assert %{^another_pack_id => 25} = original_counts |       assert %{^another_pack_id => 25} = original_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 11}, current_user, pack) |       shot_record_fixture(%{count: 11}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|       original_counts = [pack, another_pack] |> Ammo.get_original_counts(current_user) |       original_counts = [pack, another_pack] |> Ammo.get_original_counts(current_user) | ||||||
|       assert %{^pack_id => 50} = original_counts |       assert %{^pack_id => 50} = original_counts | ||||||
|       assert %{^another_pack_id => 25} = original_counts |       assert %{^another_pack_id => 25} = original_counts | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 25}, current_user, pack) |       shot_record_fixture(%{count: 25}, current_user, pack) | ||||||
|       pack = Ammo.get_pack!(pack_id, current_user) |       pack = Ammo.get_pack!(pack_id, current_user) | ||||||
|       original_counts = [pack, another_pack] |> Ammo.get_original_counts(current_user) |       original_counts = [pack, another_pack] |> Ammo.get_original_counts(current_user) | ||||||
|       assert %{^pack_id => 50} = original_counts |       assert %{^pack_id => 50} = original_counts | ||||||
|   | |||||||
| @@ -16,14 +16,14 @@ defmodule CanneryWeb.ExportControllerTest do | |||||||
|     tag = tag_fixture(current_user) |     tag = tag_fixture(current_user) | ||||||
|     Containers.add_tag!(container, tag, current_user) |     Containers.add_tag!(container, tag, current_user) | ||||||
|     {1, [pack]} = pack_fixture(ammo_type, container, current_user) |     {1, [pack]} = pack_fixture(ammo_type, container, current_user) | ||||||
|     shot_group = shot_group_fixture(current_user, pack) |     shot_record = shot_record_fixture(current_user, pack) | ||||||
|     pack = pack |> Repo.reload!() |     pack = pack |> Repo.reload!() | ||||||
|  |  | ||||||
|     %{ |     %{ | ||||||
|       ammo_type: ammo_type, |       ammo_type: ammo_type, | ||||||
|       pack: pack, |       pack: pack, | ||||||
|       container: container, |       container: container, | ||||||
|       shot_group: shot_group, |       shot_record: shot_record, | ||||||
|       tag: tag |       tag: tag | ||||||
|     } |     } | ||||||
|   end |   end | ||||||
| @@ -37,7 +37,7 @@ defmodule CanneryWeb.ExportControllerTest do | |||||||
|       container: container, |       container: container, | ||||||
|       ammo_type: ammo_type, |       ammo_type: ammo_type, | ||||||
|       pack: pack, |       pack: pack, | ||||||
|       shot_group: shot_group, |       shot_record: shot_record, | ||||||
|       tag: tag |       tag: tag | ||||||
|     } do |     } do | ||||||
|       conn = get(conn, Routes.export_path(conn, :export, :json)) |       conn = get(conn, Routes.export_path(conn, :export, :json)) | ||||||
| @@ -104,12 +104,12 @@ defmodule CanneryWeb.ExportControllerTest do | |||||||
|         "round_count" => container |> Ammo.get_round_count_for_container!(current_user) |         "round_count" => container |> Ammo.get_round_count_for_container!(current_user) | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       ideal_shot_group = %{ |       ideal_shot_record = %{ | ||||||
|         "pack_id" => shot_group.pack_id, |         "pack_id" => shot_record.pack_id, | ||||||
|         "count" => shot_group.count, |         "count" => shot_record.count, | ||||||
|         "date" => to_string(shot_group.date), |         "date" => to_string(shot_record.date), | ||||||
|         "id" => shot_group.id, |         "id" => shot_record.id, | ||||||
|         "notes" => shot_group.notes |         "notes" => shot_record.notes | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       ideal_user = %{ |       ideal_user = %{ | ||||||
| @@ -127,7 +127,7 @@ defmodule CanneryWeb.ExportControllerTest do | |||||||
|       assert %{"packs" => [^ideal_pack]} = json_resp |       assert %{"packs" => [^ideal_pack]} = json_resp | ||||||
|       assert %{"ammo_types" => [^ideal_ammo_type]} = json_resp |       assert %{"ammo_types" => [^ideal_ammo_type]} = json_resp | ||||||
|       assert %{"containers" => [^ideal_container]} = json_resp |       assert %{"containers" => [^ideal_container]} = json_resp | ||||||
|       assert %{"shot_groups" => [^ideal_shot_group]} = json_resp |       assert %{"shot_records" => [^ideal_shot_record]} = json_resp | ||||||
|       assert %{"user" => ^ideal_user} = json_resp |       assert %{"user" => ^ideal_user} = json_resp | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|   | |||||||
| @@ -37,8 +37,8 @@ defmodule CanneryWeb.AmmoTypeLiveTest do | |||||||
|     notes: "some pack", |     notes: "some pack", | ||||||
|     count: 20 |     count: 20 | ||||||
|   } |   } | ||||||
|   @shot_group_attrs %{ |   @shot_record_attrs %{ | ||||||
|     notes: "some shot group", |     notes: "some shot recorddd", | ||||||
|     count: 20 |     count: 20 | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -55,9 +55,9 @@ defmodule CanneryWeb.AmmoTypeLiveTest do | |||||||
|   defp create_empty_pack(%{ammo_type: ammo_type, current_user: current_user}) do |   defp create_empty_pack(%{ammo_type: ammo_type, current_user: current_user}) do | ||||||
|     container = container_fixture(current_user) |     container = container_fixture(current_user) | ||||||
|     {1, [pack]} = pack_fixture(@pack_attrs, ammo_type, container, current_user) |     {1, [pack]} = pack_fixture(@pack_attrs, ammo_type, container, current_user) | ||||||
|     shot_group = shot_group_fixture(@shot_group_attrs, current_user, pack) |     shot_record = shot_record_fixture(@shot_record_attrs, current_user, pack) | ||||||
|     pack = pack |> Repo.reload!() |     pack = pack |> Repo.reload!() | ||||||
|     [pack: pack, container: container, shot_group: shot_group] |     [pack: pack, container: container, shot_record: shot_record] | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   describe "Index" do |   describe "Index" do | ||||||
| @@ -275,7 +275,7 @@ defmodule CanneryWeb.AmmoTypeLiveTest do | |||||||
|       assert html =~ "\n0\n" |       assert html =~ "\n0\n" | ||||||
|       assert html =~ "\n1\n" |       assert html =~ "\n1\n" | ||||||
|  |  | ||||||
|       shot_group_fixture(%{count: 5}, current_user, pack) |       shot_record_fixture(%{count: 5}, current_user, pack) | ||||||
|  |  | ||||||
|       {:ok, index_live, _html} = live(conn, Routes.ammo_type_index_path(conn, :index)) |       {:ok, index_live, _html} = live(conn, Routes.ammo_type_index_path(conn, :index)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,18 +12,18 @@ defmodule CanneryWeb.PackLiveTest do | |||||||
|   @update_attrs %{count: 43, notes: "some updated notes", price_paid: 456.7} |   @update_attrs %{count: 43, notes: "some updated notes", price_paid: 456.7} | ||||||
|   @invalid_attrs %{count: nil, notes: nil, price_paid: nil} |   @invalid_attrs %{count: nil, notes: nil, price_paid: nil} | ||||||
|   @pack_create_limit 10_000 |   @pack_create_limit 10_000 | ||||||
|   @shot_group_create_attrs %{ammo_left: 5, notes: "some notes"} |   @shot_record_create_attrs %{ammo_left: 5, notes: "some notes"} | ||||||
|   @shot_group_update_attrs %{ |   @shot_record_update_attrs %{ | ||||||
|     count: 5, |     count: 5, | ||||||
|     date: ~N[2022-02-13 03:17:00], |     date: ~N[2022-02-13 03:17:00], | ||||||
|     notes: "some updated notes" |     notes: "some updated notes" | ||||||
|   } |   } | ||||||
|   @shot_group_invalid_attrs %{ammo_left: nil, count: nil, notes: nil} |   @shot_record_invalid_attrs %{ammo_left: nil, count: nil, notes: nil} | ||||||
|   @empty_attrs %{ |   @empty_attrs %{ | ||||||
|     price_paid: 50, |     price_paid: 50, | ||||||
|     count: 20 |     count: 20 | ||||||
|   } |   } | ||||||
|   @shot_group_attrs %{ |   @shot_record_attrs %{ | ||||||
|     price_paid: 50, |     price_paid: 50, | ||||||
|     count: 20 |     count: 20 | ||||||
|   } |   } | ||||||
| @@ -35,10 +35,10 @@ defmodule CanneryWeb.PackLiveTest do | |||||||
|     [ammo_type: ammo_type, pack: pack, container: container] |     [ammo_type: ammo_type, pack: pack, container: container] | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp create_shot_group(%{current_user: current_user, pack: pack}) do |   defp create_shot_record(%{current_user: current_user, pack: pack}) do | ||||||
|     shot_group = shot_group_fixture(@shot_group_update_attrs, current_user, pack) |     shot_record = shot_record_fixture(@shot_record_update_attrs, current_user, pack) | ||||||
|     pack = pack |> Repo.reload!() |     pack = pack |> Repo.reload!() | ||||||
|     [pack: pack, shot_group: shot_group] |     [pack: pack, shot_record: shot_record] | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp create_empty_pack(%{ |   defp create_empty_pack(%{ | ||||||
| @@ -47,9 +47,9 @@ defmodule CanneryWeb.PackLiveTest do | |||||||
|          container: container |          container: container | ||||||
|        }) do |        }) do | ||||||
|     {1, [pack]} = pack_fixture(@empty_attrs, ammo_type, container, current_user) |     {1, [pack]} = pack_fixture(@empty_attrs, ammo_type, container, current_user) | ||||||
|     shot_group = shot_group_fixture(@shot_group_attrs, current_user, pack) |     shot_record = shot_record_fixture(@shot_record_attrs, current_user, pack) | ||||||
|     pack = pack |> Repo.reload!() |     pack = pack |> Repo.reload!() | ||||||
|     [empty_pack: pack, shot_group: shot_group] |     [empty_pack: pack, shot_record: shot_record] | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   describe "Index of pack" do |   describe "Index of pack" do | ||||||
| @@ -311,20 +311,20 @@ defmodule CanneryWeb.PackLiveTest do | |||||||
|       refute has_element?(index_live, "#pack-#{pack.id}") |       refute has_element?(index_live, "#pack-#{pack.id}") | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "saves new shot_group", %{conn: conn, pack: pack} do |     test "saves new shot_record", %{conn: conn, pack: pack} do | ||||||
|       {:ok, index_live, _html} = live(conn, Routes.pack_index_path(conn, :index)) |       {:ok, index_live, _html} = live(conn, Routes.pack_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert index_live |> element("a", "Record shots") |> render_click() =~ "Record shots" |       assert index_live |> element("a", "Record shots") |> render_click() =~ "Record shots" | ||||||
|       assert_patch(index_live, Routes.pack_index_path(conn, :add_shot_group, pack)) |       assert_patch(index_live, Routes.pack_index_path(conn, :add_shot_record, pack)) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> form("#shot-group-form") |              |> form("#shot-group-form") | ||||||
|              |> render_change(shot_group: @shot_group_invalid_attrs) =~ "can't be blank" |              |> render_change(shot_record: @shot_record_invalid_attrs) =~ "can't be blank" | ||||||
|  |  | ||||||
|       {:ok, _view, html} = |       {:ok, _view, html} = | ||||||
|         index_live |         index_live | ||||||
|         |> form("#shot-group-form") |         |> form("#shot-group-form") | ||||||
|         |> render_submit(shot_group: @shot_group_create_attrs) |         |> render_submit(shot_record: @shot_record_create_attrs) | ||||||
|         |> follow_redirect(conn, Routes.pack_index_path(conn, :index)) |         |> follow_redirect(conn, Routes.pack_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert html =~ "Shots recorded successfully" |       assert html =~ "Shots recorded successfully" | ||||||
| @@ -394,66 +394,66 @@ defmodule CanneryWeb.PackLiveTest do | |||||||
|       assert html =~ "some updated notes" |       assert html =~ "some updated notes" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "saves new shot_group", %{conn: conn, pack: pack} do |     test "saves new shot_record", %{conn: conn, pack: pack} do | ||||||
|       {:ok, index_live, _html} = live(conn, Routes.pack_show_path(conn, :show, pack)) |       {:ok, index_live, _html} = live(conn, Routes.pack_show_path(conn, :show, pack)) | ||||||
|  |  | ||||||
|       assert index_live |> element("a", "Record shots") |> render_click() =~ "Record shots" |       assert index_live |> element("a", "Record shots") |> render_click() =~ "Record shots" | ||||||
|       assert_patch(index_live, Routes.pack_show_path(conn, :add_shot_group, pack)) |       assert_patch(index_live, Routes.pack_show_path(conn, :add_shot_record, pack)) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> form("#shot-group-form") |              |> form("#shot-group-form") | ||||||
|              |> render_change(shot_group: @shot_group_invalid_attrs) =~ "can't be blank" |              |> render_change(shot_record: @shot_record_invalid_attrs) =~ "can't be blank" | ||||||
|  |  | ||||||
|       {:ok, _view, html} = |       {:ok, _view, html} = | ||||||
|         index_live |         index_live | ||||||
|         |> form("#shot-group-form") |         |> form("#shot-group-form") | ||||||
|         |> render_submit(shot_group: @shot_group_create_attrs) |         |> render_submit(shot_record: @shot_record_create_attrs) | ||||||
|         |> follow_redirect(conn, Routes.pack_show_path(conn, :show, pack)) |         |> follow_redirect(conn, Routes.pack_show_path(conn, :show, pack)) | ||||||
|  |  | ||||||
|       assert html =~ "Shots recorded successfully" |       assert html =~ "Shots recorded successfully" | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   describe "Show pack with shot group" do |   describe "Show pack with shot recorddd" do | ||||||
|     setup [:register_and_log_in_user, :create_pack, :create_shot_group] |     setup [:register_and_log_in_user, :create_pack, :create_shot_record] | ||||||
|  |  | ||||||
|     test "updates shot_group in listing", |     test "updates shot_record in listing", | ||||||
|          %{conn: conn, pack: pack, shot_group: shot_group} do |          %{conn: conn, pack: pack, shot_record: shot_record} do | ||||||
|       {:ok, index_live, _html} = live(conn, Routes.pack_show_path(conn, :edit, pack)) |       {:ok, index_live, _html} = live(conn, Routes.pack_show_path(conn, :edit, pack)) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> element(~s/a[aria-label="Edit shot group of #{shot_group.count} shots"]/) |              |> element(~s/a[aria-label="Edit shot recordd of #{shot_record.count} shots"]/) | ||||||
|              |> render_click() =~ "Edit Shot Records" |              |> render_click() =~ "Edit Shot Records" | ||||||
|  |  | ||||||
|       assert_patch( |       assert_patch( | ||||||
|         index_live, |         index_live, | ||||||
|         Routes.pack_show_path(conn, :edit_shot_group, pack, shot_group) |         Routes.pack_show_path(conn, :edit_shot_record, pack, shot_record) | ||||||
|       ) |       ) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> form("#shot-group-form") |              |> form("#shot-group-form") | ||||||
|              |> render_change(shot_group: @shot_group_invalid_attrs) =~ "can't be blank" |              |> render_change(shot_record: @shot_record_invalid_attrs) =~ "can't be blank" | ||||||
|  |  | ||||||
|       {:ok, _view, html} = |       {:ok, _view, html} = | ||||||
|         index_live |         index_live | ||||||
|         |> form("#shot-group-form") |         |> form("#shot-group-form") | ||||||
|         |> render_submit(shot_group: @shot_group_update_attrs) |         |> render_submit(shot_record: @shot_record_update_attrs) | ||||||
|         |> follow_redirect(conn, Routes.pack_show_path(conn, :show, pack)) |         |> follow_redirect(conn, Routes.pack_show_path(conn, :show, pack)) | ||||||
|  |  | ||||||
|       assert html =~ "Shot records updated successfully" |       assert html =~ "Shot records updated successfully" | ||||||
|       assert html =~ "some updated notes" |       assert html =~ "some updated notes" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "deletes shot_group in listing", |     test "deletes shot_record in listing", | ||||||
|          %{conn: conn, pack: pack, shot_group: shot_group} do |          %{conn: conn, pack: pack, shot_record: shot_record} do | ||||||
|       {:ok, index_live, _html} = |       {:ok, index_live, _html} = | ||||||
|         live(conn, Routes.pack_show_path(conn, :edit_shot_group, pack, shot_group)) |         live(conn, Routes.pack_show_path(conn, :edit_shot_record, pack, shot_record)) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> element(~s/a[aria-label="Delete shot record of #{shot_group.count} shots"]/) |              |> element(~s/a[aria-label="Delete shot record of #{shot_record.count} shots"]/) | ||||||
|              |> render_click() |              |> render_click() | ||||||
|  |  | ||||||
|       refute has_element?(index_live, "#shot_group-#{shot_group.id}") |       refute has_element?(index_live, "#shot_record-#{shot_record.id}") | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|   | |||||||
| @@ -12,32 +12,32 @@ defmodule CanneryWeb.RangeLiveTest do | |||||||
|   @update_attrs %{count: 16, notes: "some updated notes"} |   @update_attrs %{count: 16, notes: "some updated notes"} | ||||||
|   @invalid_attrs %{count: nil, notes: nil} |   @invalid_attrs %{count: nil, notes: nil} | ||||||
|  |  | ||||||
|   defp create_shot_group(%{current_user: current_user}) do |   defp create_shot_record(%{current_user: current_user}) do | ||||||
|     container = container_fixture(%{staged: true}, current_user) |     container = container_fixture(%{staged: true}, current_user) | ||||||
|     ammo_type = ammo_type_fixture(current_user) |     ammo_type = ammo_type_fixture(current_user) | ||||||
|  |  | ||||||
|     {1, [pack]} = pack_fixture(%{staged: true}, ammo_type, container, current_user) |     {1, [pack]} = pack_fixture(%{staged: true}, ammo_type, container, current_user) | ||||||
|  |  | ||||||
|     shot_group = |     shot_record = | ||||||
|       %{count: 5, date: ~N[2022-02-13 03:17:00], notes: "some notes"} |       %{count: 5, date: ~N[2022-02-13 03:17:00], notes: "some notes"} | ||||||
|       |> shot_group_fixture(current_user, pack) |       |> shot_record_fixture(current_user, pack) | ||||||
|  |  | ||||||
|     [ |     [ | ||||||
|       container: container, |       container: container, | ||||||
|       ammo_type: ammo_type, |       ammo_type: ammo_type, | ||||||
|       pack: pack, |       pack: pack, | ||||||
|       shot_group: shot_group |       shot_record: shot_record | ||||||
|     ] |     ] | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   describe "Index" do |   describe "Index" do | ||||||
|     setup [:register_and_log_in_user, :create_shot_group] |     setup [:register_and_log_in_user, :create_shot_record] | ||||||
|  |  | ||||||
|     test "lists all shot_groups", %{conn: conn, shot_group: shot_group} do |     test "lists all shot_records", %{conn: conn, shot_record: shot_record} do | ||||||
|       {:ok, _index_live, html} = live(conn, Routes.range_index_path(conn, :index)) |       {:ok, _index_live, html} = live(conn, Routes.range_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert html =~ "Range day" |       assert html =~ "Range day" | ||||||
|       assert html =~ shot_group.notes |       assert html =~ shot_record.notes | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "can sort by type", |     test "can sort by type", | ||||||
| @@ -45,123 +45,123 @@ defmodule CanneryWeb.RangeLiveTest do | |||||||
|       rifle_ammo_type = ammo_type_fixture(%{class: :rifle}, current_user) |       rifle_ammo_type = ammo_type_fixture(%{class: :rifle}, current_user) | ||||||
|       {1, [rifle_pack]} = pack_fixture(rifle_ammo_type, container, current_user) |       {1, [rifle_pack]} = pack_fixture(rifle_ammo_type, container, current_user) | ||||||
|  |  | ||||||
|       rifle_shot_group = shot_group_fixture(%{notes: "group_one"}, current_user, rifle_pack) |       rifle_shot_record = shot_record_fixture(%{notes: "group_one"}, current_user, rifle_pack) | ||||||
|  |  | ||||||
|       shotgun_ammo_type = ammo_type_fixture(%{class: :shotgun}, current_user) |       shotgun_ammo_type = ammo_type_fixture(%{class: :shotgun}, current_user) | ||||||
|       {1, [shotgun_pack]} = pack_fixture(shotgun_ammo_type, container, current_user) |       {1, [shotgun_pack]} = pack_fixture(shotgun_ammo_type, container, current_user) | ||||||
|  |  | ||||||
|       shotgun_shot_group = shot_group_fixture(%{notes: "group_two"}, current_user, shotgun_pack) |       shotgun_shot_record = shot_record_fixture(%{notes: "group_two"}, current_user, shotgun_pack) | ||||||
|  |  | ||||||
|       pistol_ammo_type = ammo_type_fixture(%{class: :pistol}, current_user) |       pistol_ammo_type = ammo_type_fixture(%{class: :pistol}, current_user) | ||||||
|       {1, [pistol_pack]} = pack_fixture(pistol_ammo_type, container, current_user) |       {1, [pistol_pack]} = pack_fixture(pistol_ammo_type, container, current_user) | ||||||
|  |  | ||||||
|       pistol_shot_group = shot_group_fixture(%{notes: "group_three"}, current_user, pistol_pack) |       pistol_shot_record = shot_record_fixture(%{notes: "group_three"}, current_user, pistol_pack) | ||||||
|  |  | ||||||
|       {:ok, index_live, html} = live(conn, Routes.range_index_path(conn, :index)) |       {:ok, index_live, html} = live(conn, Routes.range_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert html =~ "All" |       assert html =~ "All" | ||||||
|  |  | ||||||
|       assert html =~ rifle_shot_group.notes |       assert html =~ rifle_shot_record.notes | ||||||
|       assert html =~ shotgun_shot_group.notes |       assert html =~ shotgun_shot_record.notes | ||||||
|       assert html =~ pistol_shot_group.notes |       assert html =~ pistol_shot_record.notes | ||||||
|  |  | ||||||
|       html = |       html = | ||||||
|         index_live |         index_live | ||||||
|         |> form(~s/form[phx-change="change_class"]/) |         |> form(~s/form[phx-change="change_class"]/) | ||||||
|         |> render_change(ammo_type: %{class: :rifle}) |         |> render_change(ammo_type: %{class: :rifle}) | ||||||
|  |  | ||||||
|       assert html =~ rifle_shot_group.notes |       assert html =~ rifle_shot_record.notes | ||||||
|       refute html =~ shotgun_shot_group.notes |       refute html =~ shotgun_shot_record.notes | ||||||
|       refute html =~ pistol_shot_group.notes |       refute html =~ pistol_shot_record.notes | ||||||
|  |  | ||||||
|       html = |       html = | ||||||
|         index_live |         index_live | ||||||
|         |> form(~s/form[phx-change="change_class"]/) |         |> form(~s/form[phx-change="change_class"]/) | ||||||
|         |> render_change(ammo_type: %{class: :shotgun}) |         |> render_change(ammo_type: %{class: :shotgun}) | ||||||
|  |  | ||||||
|       refute html =~ rifle_shot_group.notes |       refute html =~ rifle_shot_record.notes | ||||||
|       assert html =~ shotgun_shot_group.notes |       assert html =~ shotgun_shot_record.notes | ||||||
|       refute html =~ pistol_shot_group.notes |       refute html =~ pistol_shot_record.notes | ||||||
|  |  | ||||||
|       html = |       html = | ||||||
|         index_live |         index_live | ||||||
|         |> form(~s/form[phx-change="change_class"]/) |         |> form(~s/form[phx-change="change_class"]/) | ||||||
|         |> render_change(ammo_type: %{class: :pistol}) |         |> render_change(ammo_type: %{class: :pistol}) | ||||||
|  |  | ||||||
|       refute html =~ rifle_shot_group.notes |       refute html =~ rifle_shot_record.notes | ||||||
|       refute html =~ shotgun_shot_group.notes |       refute html =~ shotgun_shot_record.notes | ||||||
|       assert html =~ pistol_shot_group.notes |       assert html =~ pistol_shot_record.notes | ||||||
|  |  | ||||||
|       html = |       html = | ||||||
|         index_live |         index_live | ||||||
|         |> form(~s/form[phx-change="change_class"]/) |         |> form(~s/form[phx-change="change_class"]/) | ||||||
|         |> render_change(ammo_type: %{class: :all}) |         |> render_change(ammo_type: %{class: :all}) | ||||||
|  |  | ||||||
|       assert html =~ rifle_shot_group.notes |       assert html =~ rifle_shot_record.notes | ||||||
|       assert html =~ shotgun_shot_group.notes |       assert html =~ shotgun_shot_record.notes | ||||||
|       assert html =~ pistol_shot_group.notes |       assert html =~ pistol_shot_record.notes | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "can search for shot_group", %{conn: conn, shot_group: shot_group} do |     test "can search for shot_record", %{conn: conn, shot_record: shot_record} do | ||||||
|       {:ok, index_live, html} = live(conn, Routes.range_index_path(conn, :index)) |       {:ok, index_live, html} = live(conn, Routes.range_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert html =~ shot_group.notes |       assert html =~ shot_record.notes | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> form(~s/form[phx-change="search"]/) |              |> form(~s/form[phx-change="search"]/) | ||||||
|              |> render_change(search: %{search_term: shot_group.notes}) =~ shot_group.notes |              |> render_change(search: %{search_term: shot_record.notes}) =~ shot_record.notes | ||||||
|  |  | ||||||
|       assert_patch(index_live, Routes.range_index_path(conn, :search, shot_group.notes)) |       assert_patch(index_live, Routes.range_index_path(conn, :search, shot_record.notes)) | ||||||
|  |  | ||||||
|       refute index_live |       refute index_live | ||||||
|              |> form(~s/form[phx-change="search"]/) |              |> form(~s/form[phx-change="search"]/) | ||||||
|              |> render_change(search: %{search_term: "something_else"}) =~ shot_group.notes |              |> render_change(search: %{search_term: "something_else"}) =~ shot_record.notes | ||||||
|  |  | ||||||
|       assert_patch(index_live, Routes.range_index_path(conn, :search, "something_else")) |       assert_patch(index_live, Routes.range_index_path(conn, :search, "something_else")) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> form(~s/form[phx-change="search"]/) |              |> form(~s/form[phx-change="search"]/) | ||||||
|              |> render_change(search: %{search_term: ""}) =~ shot_group.notes |              |> render_change(search: %{search_term: ""}) =~ shot_record.notes | ||||||
|  |  | ||||||
|       assert_patch(index_live, Routes.range_index_path(conn, :index)) |       assert_patch(index_live, Routes.range_index_path(conn, :index)) | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "saves new shot_group", %{conn: conn, pack: pack} do |     test "saves new shot_record", %{conn: conn, pack: pack} do | ||||||
|       {:ok, index_live, _html} = live(conn, Routes.range_index_path(conn, :index)) |       {:ok, index_live, _html} = live(conn, Routes.range_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert index_live |> element("a", "Record shots") |> render_click() =~ "Record shots" |       assert index_live |> element("a", "Record shots") |> render_click() =~ "Record shots" | ||||||
|       assert_patch(index_live, Routes.range_index_path(conn, :add_shot_group, pack)) |       assert_patch(index_live, Routes.range_index_path(conn, :add_shot_record, pack)) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> form("#shot-group-form") |              |> form("#shot-group-form") | ||||||
|              |> render_change(shot_group: @invalid_attrs) =~ "can't be blank" |              |> render_change(shot_record: @invalid_attrs) =~ "can't be blank" | ||||||
|  |  | ||||||
|       {:ok, _view, html} = |       {:ok, _view, html} = | ||||||
|         index_live |         index_live | ||||||
|         |> form("#shot-group-form") |         |> form("#shot-group-form") | ||||||
|         |> render_submit(shot_group: @create_attrs) |         |> render_submit(shot_record: @create_attrs) | ||||||
|         |> follow_redirect(conn, Routes.range_index_path(conn, :index)) |         |> follow_redirect(conn, Routes.range_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert html =~ "Shots recorded successfully" |       assert html =~ "Shots recorded successfully" | ||||||
|       assert html =~ "some notes" |       assert html =~ "some notes" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "updates shot_group in listing", %{conn: conn, shot_group: shot_group} do |     test "updates shot_record in listing", %{conn: conn, shot_record: shot_record} do | ||||||
|       {:ok, index_live, _html} = live(conn, Routes.range_index_path(conn, :index)) |       {:ok, index_live, _html} = live(conn, Routes.range_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> element(~s/a[aria-label="Edit shot record of #{shot_group.count} shots"]/) |              |> element(~s/a[aria-label="Edit shot record of #{shot_record.count} shots"]/) | ||||||
|              |> render_click() =~ "Edit Shot Records" |              |> render_click() =~ "Edit Shot Records" | ||||||
|  |  | ||||||
|       assert_patch(index_live, Routes.range_index_path(conn, :edit, shot_group)) |       assert_patch(index_live, Routes.range_index_path(conn, :edit, shot_record)) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> form("#shot-group-form") |              |> form("#shot-group-form") | ||||||
|              |> render_change(shot_group: @invalid_attrs) =~ "can't be blank" |              |> render_change(shot_record: @invalid_attrs) =~ "can't be blank" | ||||||
|  |  | ||||||
|       {:ok, _view, html} = |       {:ok, _view, html} = | ||||||
|         index_live |         index_live | ||||||
|         |> form("#shot-group-form", shot_group: @update_attrs) |         |> form("#shot-group-form", shot_record: @update_attrs) | ||||||
|         |> render_submit() |         |> render_submit() | ||||||
|         |> follow_redirect(conn, Routes.range_index_path(conn, :index)) |         |> follow_redirect(conn, Routes.range_index_path(conn, :index)) | ||||||
|  |  | ||||||
| @@ -169,14 +169,14 @@ defmodule CanneryWeb.RangeLiveTest do | |||||||
|       assert html =~ "some updated notes" |       assert html =~ "some updated notes" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "deletes shot_group in listing", %{conn: conn, shot_group: shot_group} do |     test "deletes shot_record in listing", %{conn: conn, shot_record: shot_record} do | ||||||
|       {:ok, index_live, _html} = live(conn, Routes.range_index_path(conn, :index)) |       {:ok, index_live, _html} = live(conn, Routes.range_index_path(conn, :index)) | ||||||
|  |  | ||||||
|       assert index_live |       assert index_live | ||||||
|              |> element(~s/a[aria-label="Delete shot record of #{shot_group.count} shots"]/) |              |> element(~s/a[aria-label="Delete shot record of #{shot_record.count} shots"]/) | ||||||
|              |> render_click() |              |> render_click() | ||||||
|  |  | ||||||
|       refute has_element?(index_live, "#shot_group-#{shot_group.id}") |       refute has_element?(index_live, "#shot_record-#{shot_record.id}") | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ defmodule Cannery.Fixtures do | |||||||
|   alias Cannery.{ |   alias Cannery.{ | ||||||
|     Accounts, |     Accounts, | ||||||
|     Accounts.User, |     Accounts.User, | ||||||
|     ActivityLog.ShotGroup, |     ActivityLog.ShotRecord, | ||||||
|     Ammo, |     Ammo, | ||||||
|     Ammo.AmmoType, |     Ammo.AmmoType, | ||||||
|     Ammo.Pack, |     Ammo.Pack, | ||||||
| @@ -69,18 +69,18 @@ defmodule Cannery.Fixtures do | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   @doc """ |   @doc """ | ||||||
|   Generate a ShotGroup |   Generate a ShotRecord | ||||||
|   """ |   """ | ||||||
|   @spec shot_group_fixture(User.t(), Pack.t()) :: ShotGroup.t() |   @spec shot_record_fixture(User.t(), Pack.t()) :: ShotRecord.t() | ||||||
|   @spec shot_group_fixture(attrs :: map(), User.t(), Pack.t()) :: ShotGroup.t() |   @spec shot_record_fixture(attrs :: map(), User.t(), Pack.t()) :: ShotRecord.t() | ||||||
|   def shot_group_fixture(attrs \\ %{}, %User{} = user, %Pack{} = pack) do |   def shot_record_fixture(attrs \\ %{}, %User{} = user, %Pack{} = pack) do | ||||||
|     attrs |     attrs | ||||||
|     |> Enum.into(%{ |     |> Enum.into(%{ | ||||||
|       count: 20, |       count: 20, | ||||||
|       date: ~N[2022-02-13 03:17:00], |       date: ~N[2022-02-13 03:17:00], | ||||||
|       notes: random_string() |       notes: random_string() | ||||||
|     }) |     }) | ||||||
|     |> Cannery.ActivityLog.create_shot_group(user, pack) |     |> Cannery.ActivityLog.create_shot_record(user, pack) | ||||||
|     |> unwrap_ok_tuple() |     |> unwrap_ok_tuple() | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user