Merge branch 'performance_boosts' into 'develop'
Performance boosts See merge request gab/social/gab-social!64
This commit is contained in:
commit
559ccc7e51
1
Gemfile
1
Gemfile
@ -145,6 +145,7 @@ group :development do
|
||||
gem 'derailed_benchmarks'
|
||||
gem 'rack-mini-profiler'
|
||||
gem 'stackprof'
|
||||
gem 'benchmark-ips'
|
||||
end
|
||||
|
||||
group :production do
|
||||
|
@ -683,6 +683,7 @@ DEPENDENCIES
|
||||
addressable (~> 2.6)
|
||||
annotate (~> 2.7)
|
||||
aws-sdk-s3 (~> 1.41)
|
||||
benchmark-ips
|
||||
better_errors (~> 2.5)
|
||||
binding_of_caller (~> 0.7)
|
||||
blurhash (~> 0.1)
|
||||
|
@ -53,7 +53,7 @@ module JsonLdHelper
|
||||
needle = Addressable::URI.parse(url).host
|
||||
haystack = Addressable::URI.parse(@account.uri).host
|
||||
|
||||
!haystack.casecmp(needle).zero?
|
||||
!haystack.casecmp?(needle)
|
||||
end
|
||||
|
||||
def canonicalize(json)
|
||||
|
@ -370,7 +370,7 @@ class Formatter
|
||||
|
||||
escaped = text.chars.map do |c|
|
||||
output = begin
|
||||
if c.ord.to_s(16).length > 2 && UNICODE_ESCAPE_BLACKLIST_RE.match(c).nil?
|
||||
if c.ord > 255 && !UNICODE_ESCAPE_BLACKLIST_RE.match?(c)
|
||||
CGI.escape(c)
|
||||
else
|
||||
c
|
||||
|
@ -7,11 +7,11 @@ class TagManager
|
||||
include RoutingHelper
|
||||
|
||||
def web_domain?(domain)
|
||||
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.web_domain).zero?
|
||||
domain.nil? || domain.gsub(/[\/]/, '').casecmp?(Rails.configuration.x.web_domain)
|
||||
end
|
||||
|
||||
def local_domain?(domain)
|
||||
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.local_domain).zero?
|
||||
domain.nil? || domain.gsub(/[\/]/, '').casecmp?(Rails.configuration.x.local_domain)
|
||||
end
|
||||
|
||||
def normalize_domain(domain)
|
||||
@ -35,9 +35,9 @@ class TagManager
|
||||
end
|
||||
|
||||
def same_acct?(canonical, needle)
|
||||
return true if canonical.casecmp(needle).zero?
|
||||
return true if canonical.casecmp?(needle)
|
||||
username, domain = needle.split('@')
|
||||
local_domain?(domain) && canonical.casecmp(username).zero?
|
||||
local_domain?(domain) && canonical.casecmp?(username)
|
||||
end
|
||||
|
||||
def local_url?(url)
|
||||
|
@ -110,11 +110,12 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
return
|
||||
end
|
||||
|
||||
PINNABLE_VISIBILITIES = %w(public unlisted).freeze
|
||||
def pinnable
|
||||
current_user? &&
|
||||
current_user.account_id == object.account_id &&
|
||||
!object.reblog? &&
|
||||
%w(public unlisted).include?(object.visibility)
|
||||
PINNABLE_VISIBILITIES.include?(object.visibility)
|
||||
end
|
||||
|
||||
def pinned_by_group
|
||||
@ -122,11 +123,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def pinnable_by_group
|
||||
if object.group_id?
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
object.group_id?
|
||||
end
|
||||
|
||||
def source_requested?
|
||||
|
@ -11,7 +11,10 @@ class ActiveModel::Serializer::Reflection
|
||||
def build_association(parent_serializer, parent_serializer_options, include_slice = {})
|
||||
serializer = options[:serializer]
|
||||
|
||||
parent_serializer_options.merge!(named_contexts: serializer._named_contexts, context_extensions: serializer._context_extensions) if serializer.respond_to?(:_named_contexts)
|
||||
if serializer.respond_to?(:_named_contexts)
|
||||
parent_serializer_options[:named_contexts] = serializer._named_contexts
|
||||
parent_serializer_options[:context_extensions] = serializer._context_extensions
|
||||
end
|
||||
|
||||
association_options = {
|
||||
parent_serializer: parent_serializer,
|
||||
|
@ -2,7 +2,7 @@ require 'open-uri'
|
||||
|
||||
module OpenURI
|
||||
def self.redirectable?(uri1, uri2) # :nodoc:
|
||||
uri1.scheme.casecmp(uri2.scheme).zero? ||
|
||||
uri1.scheme.casecmp?(uri2.scheme) ||
|
||||
(/\A(?:http|https|ftp)\z/i =~ uri1.scheme && /\A(?:http|https|ftp)\z/i =~ uri2.scheme)
|
||||
end
|
||||
end
|
||||
|
@ -44,13 +44,13 @@ module GabSocial
|
||||
# Stub for Database.postgresql? from GitLab
|
||||
def self.postgresql?
|
||||
%w[postgresql postgresql_makara].any? do |adapter|
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp(adapter).zero?
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp?(adapter)
|
||||
end
|
||||
end
|
||||
|
||||
# Stub for Database.mysql? from GitLab
|
||||
def self.mysql?
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp('mysql2').zero?
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp?('mysql2')
|
||||
end
|
||||
|
||||
# Model that can be used for querying permissions of a SQL user.
|
||||
|
Loading…
Reference in New Issue
Block a user