mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
Use the same component for similar topics as search results.
This commit is contained in:
@ -149,19 +149,6 @@ class TopicsController < ApplicationController
|
||||
success ? render_serialized(topic, BasicTopicSerializer) : render_json_error(topic)
|
||||
end
|
||||
|
||||
def similar_to
|
||||
params.require(:title)
|
||||
params.require(:raw)
|
||||
title, raw = params[:title], params[:raw]
|
||||
[:title, :raw].each { |key| check_length_of(key, params[key]) }
|
||||
|
||||
# Only suggest similar topics if the site has a minimum amount of topics present.
|
||||
return render json: [] unless Topic.count_exceeds_minimum?
|
||||
|
||||
topics = Topic.similar_to(title, raw, current_user).to_a
|
||||
render_serialized(topics, TopicListItemSerializer, root: :topics)
|
||||
end
|
||||
|
||||
def feature_stats
|
||||
params.require(:category_id)
|
||||
category_id = params[:category_id].to_i
|
||||
@ -510,11 +497,6 @@ class TopicsController < ApplicationController
|
||||
topic.move_posts(current_user, post_ids_including_replies, args)
|
||||
end
|
||||
|
||||
def check_length_of(key, attr)
|
||||
str = (key == :raw) ? "body" : key.to_s
|
||||
invalid_param(key) if attr.length < SiteSetting.send("min_#{str}_similar_length")
|
||||
end
|
||||
|
||||
def check_for_status_presence(key, attr)
|
||||
invalid_param(key) unless %w(pinned pinned_globally visible closed archived).include?(attr)
|
||||
end
|
||||
|
Reference in New Issue
Block a user