daily pastebin goal
85%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ...
  2. queries = []
  3. joins = []
  4. left_outer_joins = []
  5. if query.present?
  6.   left_outer_joins << :company
  7.   left_outer_joins << {sessions: [:session_questions]}
  8.   queries << "(cases.id::text ILIKE :query OR companies.name ILIKE :query OR session_questions.response ILIKE :query)"
  9.   query_params[:query] = "%#{query}%"
  10. end
  11. if case_creator_id.present?
  12.   queries << "(cases.case_creator_id = :case_creator_id)"
  13. end
  14. self.joins(joins)
  15.     .left_outer_joins(left_outer_joins)
  16.     .where(queries.join(" AND "), query_params)
  17.     .distinct
  18.    
  19. get CASE_URL, params: { case_creator_id: creator.id, query: "Some Co. "}, headers: ...
  20.    
  21. "cases.id::text ILIKE :query OR companies.name ILIKE :query OR session_questions.response ILIKE :query AND cases.case_creator_id = :case_creator_id"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top