@@ -81,15 +81,24 @@ def format_datetime(datetime)
8181 def format_arguments ( arguments )
8282 return '-' if arguments . blank?
8383
84- # For ActiveJob format
85- if arguments . is_a? ( Hash ) && arguments [ 'arguments' ] . present?
86- return "<code>#{ arguments [ 'arguments' ] . inspect } </code>"
87- elsif arguments . is_a? ( Array ) && arguments . length == 1 && arguments [ 0 ] . is_a? ( Hash ) && arguments [ 0 ] [ 'arguments' ] . present?
88- return "<code>#{ arguments [ 0 ] [ 'arguments' ] . inspect } </code>"
84+ # Extract and format the arguments more cleanly
85+ formatted_args = if arguments . is_a? ( Hash ) && arguments [ 'arguments' ] . present?
86+ format_job_arguments ( arguments )
87+ elsif arguments . is_a? ( Array ) && arguments . length == 1 && arguments [ 0 ] . is_a? ( Hash ) && arguments [ 0 ] [ 'arguments' ] . present?
88+ format_job_arguments ( arguments [ 0 ] )
89+ else
90+ arguments . inspect
91+ end
92+
93+ if formatted_args . length <= 50
94+ "<code class='args-single-line'>#{ formatted_args } </code>"
95+ else
96+ <<-HTML
97+ < div class ="args-container ">
98+ < code class ="args-content "> #{ formatted_args } </ code>
99+ </ div>
100+ HTML
89101 end
90-
91- # For regular arguments format
92- "<code>#{ arguments . inspect } </code>"
93102 end
94103
95104 def format_hash ( hash )
@@ -102,18 +111,14 @@ def format_hash(hash)
102111 "<code>#{ formatted } </code>"
103112 end
104113
105- # Helper method to get the current request path
106114 def request_path
107- # Try to get the current path from the controller's request
108115 if defined? ( controller ) && controller . respond_to? ( :request )
109116 controller . request . path
110117 else
111- # Fallback to a default path if we can't get the current path
112118 '/solid_queue'
113119 end
114120 end
115121
116- # Helper method to get the mount point of the engine
117122 def engine_mount_point
118123 path_parts = request_path . split ( '/' )
119124 if path_parts . length >= 3
@@ -134,13 +139,24 @@ def query_params
134139 params . empty? ? '' : "&#{ params . join ( '&' ) } "
135140 end
136141
137- # Helper method to get the full path for a route
138142 def full_path ( route_name , *args )
139- # Try to use the engine routes first
140143 SolidQueueMonitor ::Engine . routes . url_helpers . send ( route_name , *args )
141144 rescue NoMethodError
142- # Fall back to main app routes
143145 Rails . application . routes . url_helpers . send ( "solid_queue_#{ route_name } " , *args )
144146 end
147+
148+ def format_job_arguments ( job_data )
149+ args = if job_data [ 'arguments' ] . is_a? ( Array )
150+ if job_data [ 'arguments' ] . first . is_a? ( Hash ) && job_data [ 'arguments' ] . first [ '_aj_ruby2_keywords' ] . present?
151+ job_data [ 'arguments' ] . first . except ( '_aj_ruby2_keywords' )
152+ else
153+ job_data [ 'arguments' ]
154+ end
155+ else
156+ job_data [ 'arguments' ]
157+ end
158+
159+ args . inspect
160+ end
145161 end
146162end
0 commit comments