fix shot records table disappearing after selecting an empty ammo class
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		| @@ -92,6 +92,25 @@ defmodule Cannery.ActivityLog do | ||||
|  | ||||
|   defp list_shot_groups_filter_type(query, _all), do: query | ||||
|  | ||||
|   @doc """ | ||||
|   Returns a count of shot records. | ||||
|  | ||||
|   ## Examples | ||||
|  | ||||
|       iex> get_shot_record_count!(%User{id: 123}) | ||||
|       3 | ||||
|  | ||||
|   """ | ||||
|   @spec get_shot_record_count!(User.t()) :: integer() | ||||
|   def get_shot_record_count!(%User{id: user_id}) do | ||||
|     Repo.one( | ||||
|       from sg in ShotGroup, | ||||
|         where: sg.user_id == ^user_id, | ||||
|         select: count(sg.id), | ||||
|         distinct: true | ||||
|     ) || 0 | ||||
|   end | ||||
|  | ||||
|   @spec list_shot_groups_for_pack(Pack.t(), User.t()) :: [ShotGroup.t()] | ||||
|   def list_shot_groups_for_pack( | ||||
|         %Pack{id: pack_id, user_id: user_id}, | ||||
|   | ||||
| @@ -127,6 +127,7 @@ defmodule CanneryWeb.RangeLive.Index do | ||||
|     original_counts = packs |> Ammo.get_original_counts(current_user) | ||||
|     cprs = packs |> Ammo.get_cprs(current_user) | ||||
|     last_used_dates = packs |> ActivityLog.get_last_used_dates(current_user) | ||||
|     shot_record_count = ActivityLog.get_shot_record_count!(current_user) | ||||
|  | ||||
|     socket | ||||
|     |> assign( | ||||
| @@ -135,7 +136,8 @@ defmodule CanneryWeb.RangeLive.Index do | ||||
|       cprs: cprs, | ||||
|       last_used_dates: last_used_dates, | ||||
|       chart_data: chart_data, | ||||
|       shot_groups: shot_groups | ||||
|       shot_groups: shot_groups, | ||||
|       shot_record_count: shot_record_count | ||||
|     ) | ||||
|   end | ||||
|  | ||||
|   | ||||
| @@ -50,7 +50,7 @@ | ||||
|  | ||||
|   <hr class="hr" /> | ||||
|  | ||||
|   <%= if @shot_groups |> Enum.empty?() and @search |> is_nil() do %> | ||||
|   <%= if @shot_record_count == 0 do %> | ||||
|     <h1 class="title text-xl text-primary-600"> | ||||
|       <%= gettext("No shots recorded") %> | ||||
|       <%= display_emoji("😔") %> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user