diff options
author | David Yip <yipdw@member.fsf.org> | 2017-12-12 02:54:13 -0600 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2017-12-12 02:54:13 -0600 |
commit | a057ed5cfea2c1c4fb21984cadae993740fb25e0 (patch) | |
tree | c965f135b8c46f679eb22e80a37550c8b985b9ea /app/models | |
parent | 04eaa1943f002865f8a0234e19c6ea4cc1d3bb6a (diff) | |
parent | 14c4a33cd9bfc1212cb362897272e5ea7d1529e5 (diff) |
Merge remote-tracking branch 'tootsuite/master' into merge-upstream
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 3 | ||||
-rw-r--r-- | app/models/list.rb | 8 | ||||
-rw-r--r-- | app/models/preview_card.rb | 2 | ||||
-rw-r--r-- | app/models/tag.rb | 2 |
4 files changed, 12 insertions, 3 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 48b17bbb8..c75ea028e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -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 ? diff --git a/app/models/list.rb b/app/models/list.rb index 910864b26..be85c3b87 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -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 diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index 5baddba8a..716b82243 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -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 diff --git a/app/models/tag.rb b/app/models/tag.rb index 0fa08e157..dc2c8d129 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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 |