forked from shibao/cannery
		
	rename ammo groups to packs
This commit is contained in:
		@@ -6,10 +6,9 @@ defmodule CanneryWeb.ExportController do
 | 
			
		||||
    ammo_types = Ammo.list_ammo_types(current_user, :all)
 | 
			
		||||
    used_counts = ammo_types |> ActivityLog.get_used_count_for_ammo_types(current_user)
 | 
			
		||||
    round_counts = ammo_types |> Ammo.get_round_count_for_ammo_types(current_user)
 | 
			
		||||
    ammo_group_counts = ammo_types |> Ammo.get_ammo_groups_count_for_types(current_user)
 | 
			
		||||
    pack_counts = ammo_types |> Ammo.get_packs_count_for_types(current_user)
 | 
			
		||||
 | 
			
		||||
    total_ammo_group_counts =
 | 
			
		||||
      ammo_types |> Ammo.get_ammo_groups_count_for_types(current_user, true)
 | 
			
		||||
    total_pack_counts = ammo_types |> Ammo.get_packs_count_for_types(current_user, true)
 | 
			
		||||
 | 
			
		||||
    average_costs = ammo_types |> Ammo.get_average_cost_for_ammo_types(current_user)
 | 
			
		||||
 | 
			
		||||
@@ -23,28 +22,28 @@ defmodule CanneryWeb.ExportController do
 | 
			
		||||
          "average_cost" => Map.get(average_costs, ammo_type_id),
 | 
			
		||||
          "round_count" => Map.get(round_counts, ammo_type_id, 0),
 | 
			
		||||
          "used_count" => Map.get(used_counts, ammo_type_id, 0),
 | 
			
		||||
          "ammo_group_count" => Map.get(ammo_group_counts, ammo_type_id, 0),
 | 
			
		||||
          "total_ammo_group_count" => Map.get(total_ammo_group_counts, ammo_type_id, 0)
 | 
			
		||||
          "pack_count" => Map.get(pack_counts, ammo_type_id, 0),
 | 
			
		||||
          "total_pack_count" => Map.get(total_pack_counts, ammo_type_id, 0)
 | 
			
		||||
        })
 | 
			
		||||
      end)
 | 
			
		||||
 | 
			
		||||
    ammo_groups = Ammo.list_ammo_groups(nil, :all, current_user, true)
 | 
			
		||||
    used_counts = ammo_groups |> ActivityLog.get_used_counts(current_user)
 | 
			
		||||
    original_counts = ammo_groups |> Ammo.get_original_counts(current_user)
 | 
			
		||||
    cprs = ammo_groups |> Ammo.get_cprs(current_user)
 | 
			
		||||
    percentages_remaining = ammo_groups |> Ammo.get_percentages_remaining(current_user)
 | 
			
		||||
    packs = Ammo.list_packs(nil, :all, current_user, true)
 | 
			
		||||
    used_counts = packs |> ActivityLog.get_used_counts(current_user)
 | 
			
		||||
    original_counts = packs |> Ammo.get_original_counts(current_user)
 | 
			
		||||
    cprs = packs |> Ammo.get_cprs(current_user)
 | 
			
		||||
    percentages_remaining = packs |> Ammo.get_percentages_remaining(current_user)
 | 
			
		||||
 | 
			
		||||
    ammo_groups =
 | 
			
		||||
      ammo_groups
 | 
			
		||||
      |> Enum.map(fn %{id: ammo_group_id} = ammo_group ->
 | 
			
		||||
        ammo_group
 | 
			
		||||
    packs =
 | 
			
		||||
      packs
 | 
			
		||||
      |> Enum.map(fn %{id: pack_id} = pack ->
 | 
			
		||||
        pack
 | 
			
		||||
        |> Jason.encode!()
 | 
			
		||||
        |> Jason.decode!()
 | 
			
		||||
        |> Map.merge(%{
 | 
			
		||||
          "used_count" => Map.get(used_counts, ammo_group_id),
 | 
			
		||||
          "percentage_remaining" => Map.fetch!(percentages_remaining, ammo_group_id),
 | 
			
		||||
          "original_count" => Map.get(original_counts, ammo_group_id),
 | 
			
		||||
          "cpr" => Map.get(cprs, ammo_group_id)
 | 
			
		||||
          "used_count" => Map.get(used_counts, pack_id),
 | 
			
		||||
          "percentage_remaining" => Map.fetch!(percentages_remaining, pack_id),
 | 
			
		||||
          "original_count" => Map.get(original_counts, pack_id),
 | 
			
		||||
          "cpr" => Map.get(cprs, pack_id)
 | 
			
		||||
        })
 | 
			
		||||
      end)
 | 
			
		||||
 | 
			
		||||
@@ -53,14 +52,14 @@ defmodule CanneryWeb.ExportController do
 | 
			
		||||
    containers =
 | 
			
		||||
      Containers.list_containers(current_user)
 | 
			
		||||
      |> Enum.map(fn container ->
 | 
			
		||||
        ammo_group_count = container |> Ammo.get_ammo_groups_count_for_container!(current_user)
 | 
			
		||||
        pack_count = container |> Ammo.get_packs_count_for_container!(current_user)
 | 
			
		||||
        round_count = container |> Ammo.get_round_count_for_container!(current_user)
 | 
			
		||||
 | 
			
		||||
        container
 | 
			
		||||
        |> Jason.encode!()
 | 
			
		||||
        |> Jason.decode!()
 | 
			
		||||
        |> Map.merge(%{
 | 
			
		||||
          "ammo_group_count" => ammo_group_count,
 | 
			
		||||
          "pack_count" => pack_count,
 | 
			
		||||
          "round_count" => round_count
 | 
			
		||||
        })
 | 
			
		||||
      end)
 | 
			
		||||
@@ -68,7 +67,7 @@ defmodule CanneryWeb.ExportController do
 | 
			
		||||
    json(conn, %{
 | 
			
		||||
      user: current_user,
 | 
			
		||||
      ammo_types: ammo_types,
 | 
			
		||||
      ammo_groups: ammo_groups,
 | 
			
		||||
      packs: packs,
 | 
			
		||||
      shot_groups: shot_groups,
 | 
			
		||||
      containers: containers
 | 
			
		||||
    })
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user