Class: SequenceServer::Routes
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- SequenceServer::Routes
- Defined in:
- lib/sequenceserver/routes.rb
Overview
Controller.
Instance Method Summary collapse
- #display_large_result_warning?(xml_file_size) ⇒ Boolean
- #large_result_warning_payload(jid) ⇒ Object
-
#update_searchdata_from_job(searchdata) ⇒ Object
Get the query sequences, selected databases, and advanced params used.
Instance Method Details
#display_large_result_warning?(xml_file_size) ⇒ Boolean
336 337 338 339 340 341 342 343 |
# File 'lib/sequenceserver/routes.rb', line 336 def display_large_result_warning?(xml_file_size) threshold = SequenceServer.config[:large_result_warning_threshold].to_i return false unless threshold.positive? return false if params[:bypass_file_size_warning] == 'true' xml_file_size > threshold end |
#large_result_warning_payload(jid) ⇒ Object
345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/sequenceserver/routes.rb', line 345 def large_result_warning_payload(jid) { user_warning: 'LARGE_RESULT', download_links: [ { name: 'Standard Tabular Report', url: "download/#{jid}.std_tsv" }, { name: 'Full Tabular Report', url: "/download/#{jid}.full_tsv" }, { name: 'Results in XML', url: "/download/#{jid}.xml" }, { name: 'Pairwise', url: "/download/#{jid}.pairwise" }, ] } end |
#update_searchdata_from_job(searchdata) ⇒ Object
Get the query sequences, selected databases, and advanced params used.
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/sequenceserver/routes.rb', line 311 def update_searchdata_from_job(searchdata) job = fetch_job(params[:job_id]) return { error: 'Job not found' }.to_json if job.nil? return if job.imported_xml_file # Only read job.qfile if we are not going to use Database.retrieve. searchdata[:query] = File.read(job.qfile) unless params[:query] # Which databases to pre-select. searchdata[:preSelectedDbs] = job.databases # job.advanced may be nil in case of old jobs. In this case, we do not # override searchdata so that default advanced parameters can be applied. # Note that, job.advanced will be an empty string if a user deletes the # default advanced parameters from the advanced params input field. In # this case, we do want the advanced params input field to be empty when # the user hits the back button. Thus we do not test for empty string. method = job.method.to_sym if job.advanced && job.advanced != searchdata.dig(:options, method, :default, :attributes).to_a.join(' ') searchdata[:options] = searchdata[:options].deep_copy searchdata[:options][method]['last search'] = { attributes: [job.advanced] } end end |