Merge remote-tracking branch 'tootsuite/master' into merge-upstream

This commit is contained in:
David Yip
2017-12-12 02:54:13 -06:00
98 changed files with 1201 additions and 426 deletions

View File

@ -287,6 +287,7 @@ class Account < ApplicationRecord
FROM accounts
WHERE #{query} @@ #{textsearch}
AND accounts.suspended = false
AND accounts.moved_to_account_id IS NULL
ORDER BY rank DESC
LIMIT ?
SQL
@ -312,6 +313,7 @@ class Account < ApplicationRecord
WHERE accounts.id IN (SELECT * FROM first_degree)
AND #{query} @@ #{textsearch}
AND accounts.suspended = false
AND accounts.moved_to_account_id IS NULL
GROUP BY accounts.id
ORDER BY rank DESC
LIMIT ?
@ -327,6 +329,7 @@ class Account < ApplicationRecord
LEFT OUTER JOIN follows AS f ON (accounts.id = f.account_id AND f.target_account_id = ?) OR (accounts.id = f.target_account_id AND f.account_id = ?)
WHERE #{query} @@ #{textsearch}
AND accounts.suspended = false
AND accounts.moved_to_account_id IS NULL
GROUP BY accounts.id
ORDER BY rank DESC
LIMIT ?

View File

@ -4,7 +4,7 @@
# Table name: lists
#
# id :integer not null, primary key
# account_id :integer
# account_id :integer not null
# title :string default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
@ -13,6 +13,8 @@
class List < ApplicationRecord
include Paginable
PER_ACCOUNT_LIMIT = 50
belongs_to :account
has_many :list_accounts, inverse_of: :list, dependent: :destroy
@ -20,6 +22,10 @@ class List < ApplicationRecord
validates :title, presence: true
validates_each :account_id, on: :create do |record, _attr, value|
record.errors.add(:base, I18n.t('lists.errors.limit')) if List.where(account_id: value).count >= PER_ACCOUNT_LIMIT
end
before_destroy :clean_feed_manager
private

View File

@ -33,7 +33,7 @@ class PreviewCard < ApplicationRecord
has_and_belongs_to_many :statuses
has_attached_file :image, styles: { original: '280x280>' }, convert_options: { all: '-quality 80 -strip' }
has_attached_file :image, styles: { original: '400x400>' }, convert_options: { all: '-quality 80 -strip' }
include Attachmentable
include Remotable

View File

@ -23,7 +23,7 @@ class Tag < ApplicationRecord
class << self
def search_for(term, limit = 5)
pattern = sanitize_sql_like(term) + '%'
pattern = sanitize_sql_like(term.strip) + '%'
Tag.where('lower(name) like lower(?)', pattern).order(:name).limit(limit)
end
end