Class: Api::V1::SearchController

Inherits:
BaseController show all
Defined in:
app/controllers/api/v1/search_controller.rb

Constant Summary collapse

USER_FILTER_CONTACTS =
"contacts"
USER_FILTER_RECEIVING_CONTACTS =
"contacts:receiving"
USER_FILTER_SHARING_CONTACTS =
"contacts:sharing"
USER_FILTER_ASPECTS_PREFIX =
"aspect:"
USER_FILTERS_EXACT_MATCH =
[USER_FILTER_CONTACTS, USER_FILTER_RECEIVING_CONTACTS,
USER_FILTER_SHARING_CONTACTS].freeze
USER_FILTERS_PREFIX_MATCH =
[USER_FILTER_ASPECTS_PREFIX].freeze

Instance Attribute Summary

Attributes included from OpenidConnect::ProtectedResourceEndpoint

#current_token

Instance Method Summary collapse

Methods included from OpenidConnect::ProtectedResourceEndpoint

#access_token?, #require_access_token

Instance Method Details

#post_indexObject


28
29
30
31
32
# File 'app/controllers/api/v1/search_controller.rb', line 28

def post_index
  posts_page = time_pager(posts_query, "posts.created_at", "created_at").response
  posts_page[:data] = posts_page[:data].map {|post| PostPresenter.new(post).as_api_response }
  render_paged_api_response posts_page
end

#tag_indexObject


34
35
36
37
38
# File 'app/controllers/api/v1/search_controller.rb', line 34

def tag_index
  tags_page = index_pager(tags_query).response
  tags_page[:data] = tags_page[:data].pluck(:name)
  render_paged_api_response tags_page
end

#user_indexObject


22
23
24
25
26
# File 'app/controllers/api/v1/search_controller.rb', line 22

def user_index
  user_page = index_pager(people_query).response
  user_page[:data] = user_page[:data].map {|p| PersonPresenter.new(p).as_api_json }
  render_paged_api_response user_page
end