diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-01-11 11:55:42 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2021-01-11 11:55:42 +0100 |
commit | 33d30632fb627ba1742eff3e0c5fc84ccd156cdb (patch) | |
tree | b7c15bb354c9d2f0ef25c50ab387007703f599d6 /lib | |
parent | d42e7e01dcd464f80637682d4eee6e5a7f36f26e (diff) | |
parent | 11d603101a7b3389c679b8c155a3cb06203ca31a (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/models/public_feed.rb`: Upstream refactored a bit, glitch-soc had specific code for local-only statuses. Updated glitch-soc's specific code accordingly.
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 |