Sha256: 43638cac5c6224116fb5aa814488d7c386614b92f7fa6a22a18aa2fa0101b96b

Contents?: true

Size: 1001 Bytes

Versions: 3

Compression:

Stored size: 1001 Bytes

Contents

module Quorum
  module JobReportSearcher

    #
    # Simple search interface on query, id and job id for job reports.
    #
    def search(algo, params)
      algo.downcase!
      klass = "quorum/#{algo}_job_report".camelize.constantize
      if params[:"#{algo}_id"].present? && params[:query].present?
        klass.where(
          "quorum_#{algo}_job_reports.id IN (?) AND query = ? " <<
          "AND #{algo}_job_id = ?",
          params[:"#{algo}_id"].split(","),
          params[:query],
          params[:id]
        )
      elsif params[:"#{algo}_id"].present?
        klass.where(
          "quorum_#{algo}_job_reports.id IN (?) AND #{algo}_job_id = ? ",
          params[:"#{algo}_id"].split(","),
          params[:id]
        )
      elsif params[:query].present?
        klass.where(
          "query = ? AND #{algo}_job_id = ?",
          params[:query],
          params[:id]
        )
      else
        klass.where("#{algo}_job_id = ?", params[:id])
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
quorum-0.8.2 app/models/quorum/job_report_searcher.rb
quorum-0.8.1 app/models/quorum/job_report_searcher.rb
quorum-0.8.0 app/models/quorum/job_report_searcher.rb