Commit b860ebdb by Your Name

candidate without inline

parent 790e719e
......@@ -45,7 +45,7 @@ APIPREFIX = CommentService::API_PREFIX
DEFAULT_PAGE = 1
DEFAULT_PER_PAGE = 20
if RACK_ENV.to_s != "test" # disable api_key auth in test environment
if RACK_ENV.to_s != "development" # disable api_key auth in test environment
before do
error 401 unless params[:api_key] == CommentService.config[:api_key]
end
......@@ -60,6 +60,7 @@ require './api/comment_threads'
require './api/comments'
require './api/users'
require './api/votes'
require './api/pins'
require './api/notifications_and_subscriptions'
if RACK_ENV.to_s == "development"
......
......@@ -5,4 +5,3 @@ elasticsearch_server: <%= ENV['SEARCH_SERVER'] || 'http://localhost:9200' %>
cache_timeout:
threads_search: 10
threads_query: 10
vote_juice_factor: 10 #when a faculty votes (the request has juice) add this vote count to content's vote count
......@@ -107,7 +107,7 @@ helpers do
end
sort_key_mapper = {
"date" => :created_at,
"date" => [:created_at],
"activity" => :last_activity_at,
"votes" => :"votes.point",
"comments" => :comment_count,
......@@ -127,7 +127,9 @@ helpers do
else
page = (params["page"] || DEFAULT_PAGE).to_i
per_page = (params["per_page"] || DEFAULT_PER_PAGE).to_i
comment_threads = comment_threads.order_by("pinned DESC, #{sort_key} #{sort_order}") if sort_key && sort_order
#comment_threads = comment_threads.order_by("pinned DESC, #{sort_key} #{sort_order}") if sort_key && sort_order
#KChugh turns out we don't need to go through all the extra work on the back end because the client is resorting anyway
comment_threads = comment_threads.order_by("#{sort_key} #{sort_order}") if sort_key && sort_order
num_pages = [1, (comment_threads.count / per_page.to_f).ceil].max
page = [num_pages, [1, page].max].min
paged_comment_threads = comment_threads.page(page).per(per_page)
......
......@@ -45,6 +45,7 @@ class CommentThread < Content
indexes :commentable_id, type: :string, index: :not_analyzed, included_in_all: false
indexes :author_id, type: :string, as: 'author_id', index: :not_analyzed, included_in_all: false
indexes :group_id, type: :integer, as: 'group_id', index: :not_analyzed, included_in_all: false
#indexes :pinned, type: :boolean, as: 'pinned', index: :not_analyzed, included_in_all: false
end
belongs_to :author, class_name: "User", inverse_of: :comment_threads, index: true#, autosave: true
......@@ -177,6 +178,7 @@ class CommentThread < Content
"tags" => tags_array,
"type" => "thread",
"group_id" => group_id,
"pinned" => pinned?,
"endorsed" => endorsed?)
if params[:recursive]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment