@@ -119,21 +119,8 @@ class Routes < Sinatra::Base
119119 report = Report . generate ( job )
120120 halt 202 unless report . done?
121121
122- display_large_result_warning =
123- SequenceServer . config [ :large_result_warning_threshold ] . to_i . positive? &&
124- params [ :bypass_file_size_warning ] != 'true' &&
125- report . xml_file_size > SequenceServer . config [ :large_result_warning_threshold ]
126-
127- if display_large_result_warning
128- halt 200 ,
129- {
130- user_warning : 'LARGE_RESULT' ,
131- download_links : [
132- { name : 'Standard Tabular Report' , url : "download/#{ jid } .std_tsv" } ,
133- { name : 'Full Tabular Report' , url : "/download/#{ jid } .full_tsv" } ,
134- { name : 'Results in XML' , url : "/download/#{ jid } .xml" }
135- ]
136- } . to_json
122+ if display_large_result_warning? ( report . xml_file_size )
123+ halt 200 , large_result_warning_payload ( jid ) . to_json
137124 end
138125
139126 report . to_json
@@ -315,6 +302,26 @@ def update_searchdata_from_job(searchdata)
315302 end
316303 end
317304
305+ def display_large_result_warning? ( xml_file_size )
306+ threshold = SequenceServer . config [ :large_result_warning_threshold ] . to_i
307+ return false unless threshold . positive?
308+
309+ return false if params [ :bypass_file_size_warning ] == 'true'
310+
311+ xml_file_size > threshold
312+ end
313+
314+ def large_result_warning_payload ( jid )
315+ {
316+ user_warning : 'LARGE_RESULT' ,
317+ download_links : [
318+ { name : 'Standard Tabular Report' , url : "download/#{ jid } .std_tsv" } ,
319+ { name : 'Full Tabular Report' , url : "/download/#{ jid } .full_tsv" } ,
320+ { name : 'Results in XML' , url : "/download/#{ jid } .xml" }
321+ ]
322+ }
323+ end
324+
318325 helpers do
319326 def root_path_prefix
320327 settings . root_path_prefix . to_s
0 commit comments