app/models/saved_search/saved_search_store.rb
# create a query using the state of this Search instance.
create a query using the state of this Search instance.
create a query using the state of this Search instance .
def create_raw_query
    recordings_search = AudioRecording.scoped
    if self.invalid?
      raise ArgumentError, "SavedSearchStore has errors: #{self.errors.to_json}."
    end
    unless self.pre_params.blank?
      if self.pre_params.invalid?
        raise ArgumentError, "SavedSearchStorePre has errors: #{self.pre_params.errors.to_json}."
      end
    end
    unless self.body_params.blank?
      if self.body_params.invalid?
        raise ArgumentError, "SavedSearchStoreBody has errors: #{self.body_params.errors.to_json}."
      end
      recordings_search = recordings_search.recording_ids(self.body_params.audio_recording_id) if self.body_params.audio_recording_id
      recordings_search = recordings_search.recording_uuids(self.body_params.audio_recording_uuid) if self.body_params.audio_recording_uuid
      recordings_search = recordings_search.recording_projects(self.body_params.project_id) if  self.body_params.project_id
      recordings_search = recordings_search.recording_sites(self.body_params.site_id) if  self.body_params.site_id
      if  self.body_params.date_start && self.body_params.date_end
        recordings_search = recordings_search.recording_within_date(self.body_params.date_start, self.body_params.date_end)
      elsif self.body_params.date_start
        recordings_search = recordings_search.recording_within_date(self.body_params.date_start, self.body_params.date_start)
      elsif self.body_params.date_end
        recordings_search = recordings_search.recording_within_date(self.body_params.date_end, self.body_params.date_end)
      end
      if self.body_params.time_start && self.body_params.time_end
        recordings_search = recordings_search.recording_within_time(self.body_params.time_start, self.body_params.time_end)
      elsif self.body_params.time_start
        recordings_search = recordings_search.recording_within_time(self.body_params.time_start, self.body_params.time_start)
      elsif self.body_params.time_end
        recordings_search = recordings_search.recording_within_time(self.body_params.time_end, self.body_params.time_end)
      end
      recordings_search = recordings_search.recording_tags(self.body_params.tags) if self.body_params.tags
    end
    unless self.post_params.blank?
      if self.post_params.invalid?
        raise ArgumentError, "SavedSearchStorePost has errors: #{self.post_params.errors}."
      end
    end
    recordings_search
  end
def create_raw_query recordings_search = AudioRecording . scoped if self . invalid? raise ArgumentError , "SavedSearchStore has errors: #{self.errors.to_json}." end unless self . pre_params . blank? if self . pre_params . invalid? raise ArgumentError , "SavedSearchStorePre has errors: #{self.pre_params.errors.to_json}." end end unless self . body_params . blank? if self . body_params . invalid? raise ArgumentError , "SavedSearchStoreBody has errors: #{self.body_params.errors.to_json}." end recordings_search = recordings_search . recording_ids ( self . body_params . audio_recording_id ) if self . body_params . audio_recording_id recordings_search = recordings_search . recording_uuids ( self . body_params . audio_recording_uuid ) if self . body_params . audio_recording_uuid recordings_search = recordings_search . recording_projects ( self . body_params . project_id ) if self . body_params . project_id recordings_search = recordings_search . recording_sites ( self . body_params . site_id ) if self . body_params . site_id if self . body_params . date_start && self . body_params . date_end recordings_search = recordings_search . recording_within_date ( self . body_params . date_start , self . body_params . date_end ) elsif self . body_params . date_start recordings_search = recordings_search . recording_within_date ( self . body_params . date_start , self . body_params . date_start ) elsif self . body_params . date_end recordings_search = recordings_search . recording_within_date ( self . body_params . date_end , self . body_params . date_end ) end if self . body_params . time_start && self . body_params . time_end recordings_search = recordings_search . recording_within_time ( self . body_params . time_start , self . body_params . time_end ) elsif self . body_params . time_start recordings_search = recordings_search . recording_within_time ( self . body_params . time_start , self . body_params . time_start ) elsif self . body_params . time_end recordings_search = recordings_search . recording_within_time ( self . body_params . time_end , self . body_params . time_end ) end recordings_search = recordings_search . recording_tags ( self . body_params . tags ) if self . body_params . tags end unless self . post_params . blank? if self . post_params . invalid? raise ArgumentError , "SavedSearchStorePost has errors: #{self.post_params.errors}." end end recordings_search end
create a query using the state of this Search instance.
create a query using the state of this Search instance .
# these are in a specific order, from the ones that will filter the most, to those that will filter the least.