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