@@ -108,6 +108,20 @@ defmodule ReencodarrWeb.FailuresLive do
108108 { :noreply , put_flash ( socket , :info , "All failed videos have been reset" ) }
109109 end
110110
111+ @ impl true
112+ def handle_event ( "retry_failure_code" , % { "code" => failure_code } , socket ) do
113+ result = Media . retry_failed_videos_by_failure_code ( failure_code )
114+
115+ socket = load_failures_data ( socket )
116+
117+ { :noreply ,
118+ put_flash (
119+ socket ,
120+ :info ,
121+ "Queued retry for #{ result . videos_retried } failed videos with #{ failure_code } "
122+ ) }
123+ end
124+
111125 @ impl true
112126 def handle_event ( "toggle_details" , % { "video_id" => video_id } , socket ) do
113127 video_id = Parsers . parse_int ( video_id )
@@ -392,6 +406,33 @@ defmodule ReencodarrWeb.FailuresLive do
392406 </ div >
393407 </ div >
394408 </ div >
409+
410+ <%= if @ failure_code_actions != [ ] do %>
411+ < div class = "bg-gray-800 rounded-lg shadow-lg p-4 border border-gray-700 " >
412+ < div class = "flex flex-col gap-3 " >
413+ < div >
414+ < h2 class = "text-sm font-semibold text-white " > Retry By Error Code</ h2 >
415+ < p class = "text-xs text-gray-400 " >
416+ Retry all failed videos whose unresolved failures include the selected code by sending them back to analysis.
417+ </ p >
418+ </ div >
419+ < div class = "flex flex-wrap gap-2 " >
420+ <%= for action <- @ failure_code_actions do %>
421+ < button
422+ phx-click = "retry_failure_code "
423+ phx-value-code = { action . code }
424+ class = "inline-flex items-center gap-2 rounded-lg border border-gray-600 bg-gray-750 px-3 py-2 text-xs font-medium text-gray-200 transition-colors hover:bg-gray-700 "
425+ >
426+ < span > { action . code } </ span >
427+ < span class = "rounded bg-gray-900 px-1.5 py-0.5 text-[11px] text-gray-300 " >
428+ { action . count }
429+ </ span >
430+ </ button >
431+ <% end %>
432+ </ div >
433+ </ div >
434+ </ div >
435+ <% end %>
395436
396437 <!-- Failed Videos Table -->
397438 < div class = "bg-gray-800 rounded-lg shadow-lg overflow-hidden border border-gray-700 " >
@@ -741,6 +782,7 @@ defmodule ReencodarrWeb.FailuresLive do
741782 |> assign ( :video_failures , % { } )
742783 |> assign ( :failure_stats , % { recent_count: 0 } )
743784 |> assign ( :failure_patterns , [ ] )
785+ |> assign ( :failure_code_actions , [ ] )
744786 |> assign ( :total_count , 0 )
745787 |> assign ( :total_pages , 0 )
746788 end
@@ -763,6 +805,7 @@ defmodule ReencodarrWeb.FailuresLive do
763805 # Get failure statistics and patterns
764806 failure_stats = Media . get_failure_statistics ( days_back: 7 )
765807 failure_patterns = Media . get_common_failure_patterns ( 5 )
808+ failure_code_actions = Media . list_failed_video_failure_codes ( )
766809
767810 # Calculate pagination info
768811 total_pages = ceil ( total_count / per_page )
@@ -773,6 +816,7 @@ defmodule ReencodarrWeb.FailuresLive do
773816 |> assign ( :video_failures , video_failures )
774817 |> assign ( :failure_stats , summarize_failure_stats ( failure_stats ) )
775818 |> assign ( :failure_patterns , failure_patterns )
819+ |> assign ( :failure_code_actions , failure_code_actions )
776820 |> assign ( :total_count , total_count )
777821 |> assign ( :total_pages , total_pages )
778822 end
0 commit comments