Refactor: Move Topic Details into better objects, identity map, tests, query string filters

This commit is contained in:
Robin Ward
2013-06-20 17:20:08 -04:00
parent d051e35000
commit 5770879472
56 changed files with 1854 additions and 1244 deletions

View File

@ -25,12 +25,11 @@ class TopicsController < ApplicationController
caches_action :avatar, cache_path: Proc.new {|c| "#{c.params[:post_number]}-#{c.params[:topic_id]}" }
def show
# We'd like to migrate the wordpress feed to another url. This keeps up backwards compatibility with
# existing installs.
return wordpress if params[:best].present?
opts = params.slice(:username_filters, :best_of, :page, :post_number, :posts_before, :posts_after)
opts = params.slice(:username_filters, :filter, :page, :post_number)
begin
@topic_view = TopicView.new(params[:id] || params[:topic_id], current_user, opts)
rescue Discourse::NotFound
@ -67,7 +66,15 @@ class TopicsController < ApplicationController
wordpress_serializer = TopicViewWordpressSerializer.new(@topic_view, scope: guardian, root: false)
render_json_dump(wordpress_serializer)
end
end
def posts
params.require(:topic_id)
params.require(:post_ids)
@topic_view = TopicView.new(params[:topic_id], current_user, post_ids: params[:post_ids])
render_json_dump(TopicViewPostsSerializer.new(@topic_view, scope: guardian, root: false))
end
def destroy_timings