Commit ceaf5c0c by Rocky Duan

modified search

parent 1e31c03a
...@@ -63,7 +63,7 @@ get "#{APIPREFIX}/search/threads/recent_active" do ...@@ -63,7 +63,7 @@ get "#{APIPREFIX}/search/threads/recent_active" do
"today" => Date.today.to_time, "today" => Date.today.to_time,
"this_week" => Date.today.to_time - 1.weeks, "this_week" => Date.today.to_time - 1.weeks,
"this_month" => Date.today.to_time - 1.months, "this_month" => Date.today.to_time - 1.months,
}[params["from_time"] || "today"] }[params["from_time"] || "this_week"]
query_params = {} query_params = {}
query_params["course_id"] = params["course_id"] if params["course_id"] query_params["course_id"] = params["course_id"] if params["course_id"]
......
...@@ -33,7 +33,16 @@ APIPREFIX = CommentService::API_PREFIX ...@@ -33,7 +33,16 @@ APIPREFIX = CommentService::API_PREFIX
DEFAULT_PAGE = 1 DEFAULT_PAGE = 1
DEFAULT_PER_PAGE = 20 DEFAULT_PER_PAGE = 20
Dir[File.dirname(__FILE__) + '/api/*.rb'].each {|file| require file} # these files must be required in order
require './api/search'
require './api/commentables'
require './api/comment_threads'
require './api/comments'
require './api/users'
require './api/votes'
require './api/tags'
require './api/notifications_and_subscriptions'
if environment.to_s == "development" if environment.to_s == "development"
get "#{APIPREFIX}/clean" do get "#{APIPREFIX}/clean" do
......
...@@ -82,6 +82,7 @@ class CommentThread < Content ...@@ -82,6 +82,7 @@ class CommentThread < Content
end end
def self.perform_search(params, options={}) def self.perform_search(params, options={})
puts "params: #{params}"
page = [1, options[:page] || 1].max page = [1, options[:page] || 1].max
per_page = options[:per_page] || 20 per_page = options[:per_page] || 20
sort_key = options[:sort_key] sort_key = options[:sort_key]
......
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