mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
Big commit:
- Support for a popup that shows similar topics - Cleaned up a lot of Javascript - Cleaned up use of Promises
This commit is contained in:
@ -213,8 +213,22 @@ class Topic < ActiveRecord::Base
|
||||
id).to_a
|
||||
end
|
||||
|
||||
def update_status(property, status, user)
|
||||
# Search for similar topics
|
||||
def self.similar_to(title, raw)
|
||||
return [] unless title.present?
|
||||
return [] unless raw.present?
|
||||
|
||||
# For now, we only match on title. We'll probably add body later on, hence the API hook
|
||||
Topic.select(sanitize_sql_array(["topics.*, similarity(topics.title, :title) AS similarity", title: title]))
|
||||
.visible
|
||||
.where(closed: false, archived: false)
|
||||
.listable_topics
|
||||
.limit(5)
|
||||
.order('similarity desc')
|
||||
.all
|
||||
end
|
||||
|
||||
def update_status(property, status, user)
|
||||
Topic.transaction do
|
||||
|
||||
# Special case: if it's pinned, update that
|
||||
@ -592,7 +606,6 @@ class Topic < ActiveRecord::Base
|
||||
|
||||
def clear_pin_for(user)
|
||||
return unless user.present?
|
||||
|
||||
TopicUser.change(user.id, id, cleared_pinned_at: Time.now)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user