diff --git a/app/controllers/mpa/pept2filtered_controller.rb b/app/controllers/mpa/pept2filtered_controller.rb index 6520972..63dac3c 100644 --- a/app/controllers/mpa/pept2filtered_controller.rb +++ b/app/controllers/mpa/pept2filtered_controller.rb @@ -1,6 +1,10 @@ class Mpa::Pept2filteredController < Mpa::MpaController include SuffixArrayHelper + def get_time + Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond) + end + def pept2filtered peptides = (params[:peptides] || []).uniq missed = params[:missed].nil? ? false : params[:missed] @@ -15,11 +19,15 @@ def pept2filtered taxa_filter_ids = (params[:taxa] || []).map(&:to_i) + index_time = get_time + # Request the suffix array search service @response = search(peptides, equate_il, cutoff) .select { |result| !result["cutoff_used"] } .each { |result| result["taxa"] = result["taxa"].to_set } + end_index_time = get_time - index_time + taxa_filter_ids.each_slice(5000) do |taxa_slice| taxa_slice = Taxon.where(id: taxa_slice).where(valid_taxon: 1).pluck(:id).to_set @@ -29,5 +37,7 @@ def pept2filtered result["taxa"] = result["taxa"].select { |taxon_id| taxa_slice.include?(taxon_id) }.uniq end end + + @timings = end_index_time end end diff --git a/app/views/mpa/pept2filtered/pept2filtered.json.jbuilder b/app/views/mpa/pept2filtered/pept2filtered.json.jbuilder index c576bc9..b20746a 100644 --- a/app/views/mpa/pept2filtered/pept2filtered.json.jbuilder +++ b/app/views/mpa/pept2filtered/pept2filtered.json.jbuilder @@ -6,3 +6,4 @@ json.peptides @response do |peptide| json.data peptide["fa"]["data"] end end +json.timings @timings