diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/enumerable.rb | 26 | ||||
-rw-r--r-- | lib/mastodon/maintenance_cli.rb | 6 | ||||
-rw-r--r-- | lib/paperclip/attachment_extensions.rb | 2 | ||||
-rw-r--r-- | lib/paperclip/color_extractor.rb | 2 |
4 files changed, 34 insertions, 2 deletions
diff --git a/lib/enumerable.rb b/lib/enumerable.rb new file mode 100644 index 000000000..66918f65e --- /dev/null +++ b/lib/enumerable.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Enumerable + # TODO: Remove this once stop to support Ruby 2.6 + if RUBY_VERSION < '2.7.0' + def filter_map + if block_given? + result = [] + each do |element| + res = yield element + result << res if res + end + result + else + Enumerator.new do |yielder| + result = [] + each do |element| + res = yielder.yield element + result << res if res + end + result + end + end + end + end +end diff --git a/lib/mastodon/maintenance_cli.rb b/lib/mastodon/maintenance_cli.rb index 822051ceb..029d42a05 100644 --- a/lib/mastodon/maintenance_cli.rb +++ b/lib/mastodon/maintenance_cli.rb @@ -160,6 +160,7 @@ module Mastodon deduplicate_tags! deduplicate_webauthn_credentials! + Scenic.database.refresh_materialized_view('instances', concurrently: true, cascade: false) if ActiveRecord::Migrator.current_version >= 2020_12_06_004238 Rails.cache.clear @prompt.say 'Finished!' @@ -188,6 +189,11 @@ module Mastodon else ActiveRecord::Base.connection.add_index :accounts, "lower (username), COALESCE(lower(domain), '')", name: 'index_accounts_on_username_and_domain_lower', unique: true end + + @prompt.say 'Reindexing textual indexes on accounts…' + ActiveRecord::Base.connection.execute('REINDEX INDEX search_index;') + ActiveRecord::Base.connection.execute('REINDEX INDEX index_accounts_on_uri;') + ActiveRecord::Base.connection.execute('REINDEX INDEX index_accounts_on_url;') end def deduplicate_users! diff --git a/lib/paperclip/attachment_extensions.rb b/lib/paperclip/attachment_extensions.rb index 94f7769b6..e25a34213 100644 --- a/lib/paperclip/attachment_extensions.rb +++ b/lib/paperclip/attachment_extensions.rb @@ -27,7 +27,7 @@ module Paperclip return true if original_filename == other_filename return false if original_filename.nil? - formats = styles.values.map(&:format).compact + formats = styles.values.filter_map(&:format) return false if formats.empty? diff --git a/lib/paperclip/color_extractor.rb b/lib/paperclip/color_extractor.rb index f850dc067..a70a3d21f 100644 --- a/lib/paperclip/color_extractor.rb +++ b/lib/paperclip/color_extractor.rb @@ -142,7 +142,7 @@ module Paperclip g = 0.0 b = 0.0 - if s == 0.0 + if s.zero? r = l.to_f g = l.to_f b = l.to_f # achromatic |