yiffspace 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -10
- data/README.md +18 -1
- data/Rakefile +6 -7
- data/lib/yiffspace/version.rb +1 -1
- data/lib/yiffspace.rb +26 -28
- metadata +104 -148
- data/app/assets/config/yiffspace_manifest.js +0 -1
- data/app/assets/stylesheets/yiffspace/application.css +0 -30
- data/app/controllers/yiff_space/application_controller.rb +0 -6
- data/app/helpers/yiff_space/application_helper.rb +0 -6
- data/app/models/yiff_space/application_record.rb +0 -7
- data/app/views/layouts/yiff_space/application.html.erb +0 -17
- data/app/views/yiff_space/error.html.erb +0 -3
- data/lib/generators/yiffspace/fixer/USAGE +0 -40
- data/lib/generators/yiffspace/fixer/fixer_generator.rb +0 -86
- data/lib/generators/yiffspace/fixer/templates/fixer.rb +0 -4
- data/lib/generators/yiffspace/install/fixes_generator.rb +0 -21
- data/lib/generators/yiffspace/install/templates/create_fixes.rb.erb +0 -18
- data/lib/tasks/fixes.rake +0 -66
- data/lib/yiffspace/concerns/active_record_extensions.rb +0 -45
- data/lib/yiffspace/concerns/api_methods.rb +0 -101
- data/lib/yiffspace/concerns/attribute_matchers.rb +0 -100
- data/lib/yiffspace/concerns/attribute_methods.rb +0 -39
- data/lib/yiffspace/concerns/concurrency_methods.rb +0 -20
- data/lib/yiffspace/concerns/conditional_includes.rb +0 -43
- data/lib/yiffspace/concerns/current_methods.rb +0 -60
- data/lib/yiffspace/concerns/has_bit_flags.rb +0 -59
- data/lib/yiffspace/concerns/user_class_methods.rb +0 -32
- data/lib/yiffspace/concerns/user_methods.rb +0 -77
- data/lib/yiffspace/concerns/user_name_methods.rb +0 -53
- data/lib/yiffspace/concerns/user_resolvable_methods.rb +0 -38
- data/lib/yiffspace/config_builder.rb +0 -192
- data/lib/yiffspace/configuration/fixer_templates.rb +0 -87
- data/lib/yiffspace/configuration/images.rb +0 -22
- data/lib/yiffspace/configuration.rb +0 -130
- data/lib/yiffspace/core_ext/active_record/all.rb +0 -8
- data/lib/yiffspace/core_ext/active_record/cross_join_lateral.rb +0 -7
- data/lib/yiffspace/core_ext/active_record/cross_unnest.rb +0 -7
- data/lib/yiffspace/core_ext/active_record/left_join_lateral.rb +0 -7
- data/lib/yiffspace/core_ext/active_record/left_unnest.rb +0 -7
- data/lib/yiffspace/core_ext/active_record/unnest.rb +0 -8
- data/lib/yiffspace/core_ext/active_record/where_chain.rb +0 -6
- data/lib/yiffspace/core_ext/all.rb +0 -8
- data/lib/yiffspace/core_ext/arel/all.rb +0 -4
- data/lib/yiffspace/core_ext/arel/cross_join_lateral.rb +0 -21
- data/lib/yiffspace/core_ext/arel/left_join_lateral.rb +0 -21
- data/lib/yiffspace/core_ext/enumerable/all.rb +0 -3
- data/lib/yiffspace/core_ext/enumerable/parallel.rb +0 -7
- data/lib/yiffspace/core_ext/hash/all.rb +0 -3
- data/lib/yiffspace/core_ext/hash/to_open_hash.rb +0 -7
- data/lib/yiffspace/core_ext/object/all.rb +0 -4
- data/lib/yiffspace/core_ext/object/to_b.rb +0 -7
- data/lib/yiffspace/core_ext/object/truthy_falsy.rb +0 -7
- data/lib/yiffspace/core_ext/string/all.rb +0 -3
- data/lib/yiffspace/core_ext/string/sql.rb +0 -7
- data/lib/yiffspace/engine.rb +0 -23
- data/lib/yiffspace/extensions/active_record/cross_join_lateral.rb +0 -23
- data/lib/yiffspace/extensions/active_record/cross_unnest.rb +0 -15
- data/lib/yiffspace/extensions/active_record/left_join_lateral.rb +0 -24
- data/lib/yiffspace/extensions/active_record/left_unnest.rb +0 -15
- data/lib/yiffspace/extensions/active_record/unnest.rb +0 -20
- data/lib/yiffspace/extensions/active_record/where_chain.rb +0 -107
- data/lib/yiffspace/extensions/arel/nodes/cross_join_lateral.rb +0 -17
- data/lib/yiffspace/extensions/arel/nodes/left_join_lateral.rb +0 -17
- data/lib/yiffspace/extensions/arel/table/cross_join_lateral.rb +0 -15
- data/lib/yiffspace/extensions/arel/table/left_join_lateral.rb +0 -15
- data/lib/yiffspace/extensions/arel/visitors/postgresql/cross_join_lateral.rb +0 -19
- data/lib/yiffspace/extensions/arel/visitors/postgresql/left_join_lateral.rb +0 -23
- data/lib/yiffspace/extensions/enumerable/parallel.rb +0 -39
- data/lib/yiffspace/extensions/hash/to_open_hash.rb +0 -15
- data/lib/yiffspace/extensions/object/to_b.rb +0 -22
- data/lib/yiffspace/extensions/object/truthy_falsy.rb +0 -35
- data/lib/yiffspace/extensions/string/sql.rb +0 -21
- data/lib/yiffspace/fix_tracker.rb +0 -95
- data/lib/yiffspace/fixer_template.rb +0 -44
- data/lib/yiffspace/images/avatar/base.rb +0 -41
- data/lib/yiffspace/images/avatar/discord.rb +0 -37
- data/lib/yiffspace/images/avatar/gravatar.rb +0 -21
- data/lib/yiffspace/images/avatar.rb +0 -33
- data/lib/yiffspace/images/banner/base.rb +0 -41
- data/lib/yiffspace/images/banner/discord.rb +0 -37
- data/lib/yiffspace/images/banner.rb +0 -33
- data/lib/yiffspace/images.rb +0 -6
- data/lib/yiffspace/include/active_record_extensions.rb +0 -5
- data/lib/yiffspace/include/all.rb +0 -31
- data/lib/yiffspace/include/api_methods.rb +0 -5
- data/lib/yiffspace/include/attribute_matchers.rb +0 -5
- data/lib/yiffspace/include/attribute_methods.rb +0 -5
- data/lib/yiffspace/include/cache.rb +0 -5
- data/lib/yiffspace/include/concurrency_methods.rb +0 -5
- data/lib/yiffspace/include/conditional_includes.rb +0 -5
- data/lib/yiffspace/include/current.rb +0 -5
- data/lib/yiffspace/include/current_methods.rb +0 -5
- data/lib/yiffspace/include/duration_parser.rb +0 -5
- data/lib/yiffspace/include/has_bit_flags.rb +0 -5
- data/lib/yiffspace/include/helpers.rb +0 -5
- data/lib/yiffspace/include/open_hash.rb +0 -5
- data/lib/yiffspace/include/parameter_builder.rb +0 -5
- data/lib/yiffspace/include/parse_value.rb +0 -5
- data/lib/yiffspace/include/query_builder.rb +0 -5
- data/lib/yiffspace/include/query_dsl.rb +0 -5
- data/lib/yiffspace/include/query_helper.rb +0 -5
- data/lib/yiffspace/include/routes.rb +0 -5
- data/lib/yiffspace/include/table_builder.rb +0 -5
- data/lib/yiffspace/include/trace_logger.rb +0 -5
- data/lib/yiffspace/include/u2id.rb +0 -5
- data/lib/yiffspace/include/user_attribute.rb +0 -5
- data/lib/yiffspace/include/user_class_methods.rb +0 -5
- data/lib/yiffspace/include/user_like.rb +0 -5
- data/lib/yiffspace/include/user_methods.rb +0 -5
- data/lib/yiffspace/include/user_name_methods.rb +0 -5
- data/lib/yiffspace/include/user_resolvable.rb +0 -5
- data/lib/yiffspace/include/user_resolvable_methods.rb +0 -5
- data/lib/yiffspace/search/query_builder.rb +0 -83
- data/lib/yiffspace/search/query_dsl.rb +0 -119
- data/lib/yiffspace/search/query_helper.rb +0 -49
- data/lib/yiffspace/serializers/avatar_serializer.rb +0 -21
- data/lib/yiffspace/serializers/banner_serializer.rb +0 -21
- data/lib/yiffspace/serializers/user_resolvable_serializer.rb +0 -21
- data/lib/yiffspace/utils/cache.rb +0 -40
- data/lib/yiffspace/utils/current.rb +0 -43
- data/lib/yiffspace/utils/duration_parser.rb +0 -24
- data/lib/yiffspace/utils/helpers.rb +0 -25
- data/lib/yiffspace/utils/open_hash.rb +0 -63
- data/lib/yiffspace/utils/parameter_builder.rb +0 -121
- data/lib/yiffspace/utils/parse_value.rb +0 -174
- data/lib/yiffspace/utils/routes.rb +0 -28
- data/lib/yiffspace/utils/set_env_constraint.rb +0 -18
- data/lib/yiffspace/utils/table_builder.rb +0 -169
- data/lib/yiffspace/utils/trace_logger.rb +0 -91
- data/lib/yiffspace/utils/user_attribute.rb +0 -272
- data/lib/yiffspace/utils/user_like.rb +0 -8
- data/lib/yiffspace/utils/user_resolvable.rb +0 -61
- data/lib/yiffspace/utils/user_to_id.rb +0 -11
- data/lib/yiffspace/utils.rb +0 -6
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative("../../extensions/arel/nodes/cross_join_lateral")
|
|
4
|
-
require_relative("../../extensions/arel/visitors/postgresql/cross_join_lateral")
|
|
5
|
-
require_relative("../../extensions/arel/table/cross_join_lateral")
|
|
6
|
-
|
|
7
|
-
module Arel
|
|
8
|
-
module Nodes
|
|
9
|
-
CrossJoinLateral = YiffSpace::Extensions::Arel::Nodes::CrossJoinLateral
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
module Visitors
|
|
13
|
-
class PostgreSQL
|
|
14
|
-
include(YiffSpace::Extensions::Arel::Visitors::PostgreSQL::CrossJoinLateral)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
class Table
|
|
19
|
-
include(YiffSpace::Extensions::Arel::Table::CrossJoinLateral)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative("../../extensions/arel/nodes/left_join_lateral")
|
|
4
|
-
require_relative("../../extensions/arel/visitors/postgresql/left_join_lateral")
|
|
5
|
-
require_relative("../../extensions/arel/table/left_join_lateral")
|
|
6
|
-
|
|
7
|
-
module Arel
|
|
8
|
-
module Nodes
|
|
9
|
-
LeftJoinLateral = YiffSpace::Extensions::Arel::Nodes::LeftJoinLateral
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
module Visitors
|
|
13
|
-
class PostgreSQL
|
|
14
|
-
include(YiffSpace::Extensions::Arel::Visitors::PostgreSQL::LeftJoinLateral)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
class Table
|
|
19
|
-
include(YiffSpace::Extensions::Arel::Table::LeftJoinLateral)
|
|
20
|
-
end
|
|
21
|
-
end
|
data/lib/yiffspace/engine.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require("rails")
|
|
4
|
-
|
|
5
|
-
module YiffSpace
|
|
6
|
-
class Engine < ::Rails::Engine
|
|
7
|
-
config.root = File.expand_path("../..", __dir__)
|
|
8
|
-
|
|
9
|
-
initializer("yiffspace.assets") do |app|
|
|
10
|
-
app.config.assets.precompile += %w[yiffspace/application.css] if app.config.respond_to?(:assets)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
initializer("yiffspace.serializers") do
|
|
14
|
-
ActiveSupport.on_load(:active_job) do
|
|
15
|
-
ActiveJob::Serializers.add_serializers(
|
|
16
|
-
Serializers::AvatarSerializer,
|
|
17
|
-
Serializers::BannerSerializer,
|
|
18
|
-
Serializers::UserResolvableSerializer,
|
|
19
|
-
)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module ActiveRecord
|
|
6
|
-
module CrossJoinLateral
|
|
7
|
-
def cross_join_lateral(relation)
|
|
8
|
-
raise(ArgumentError, "The method .cross_join_lateral() must contain arguments.") if relation.nil?
|
|
9
|
-
|
|
10
|
-
relation = relation.arel if relation.respond_to?(:arel)
|
|
11
|
-
spawn.cross_join_lateral!(relation)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def cross_join_lateral!(relation) # :nodoc:
|
|
15
|
-
manager = klass.arel_table.cross_join_lateral(relation)
|
|
16
|
-
|
|
17
|
-
self.joins_values |= [manager.join_sources.first]
|
|
18
|
-
self
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module ActiveRecord
|
|
6
|
-
module CrossUnnest
|
|
7
|
-
def cross_unnest(column, as: column.singularize)
|
|
8
|
-
raise(ArgumentError, "The method .cross_unnest() must contain arguments.") if column.nil?
|
|
9
|
-
|
|
10
|
-
spawn.unnest(column, as: as, type: :cross_join_lateral)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module ActiveRecord
|
|
6
|
-
module LeftJoinLateral
|
|
7
|
-
def left_join_lateral(relation, on: nil)
|
|
8
|
-
raise(ArgumentError, "The method .left_join_lateral() must contain arguments.") if relation.nil?
|
|
9
|
-
|
|
10
|
-
relation = relation.arel if relation.respond_to?(:arel)
|
|
11
|
-
spawn.left_join_lateral!(relation, on: on)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def left_join_lateral!(relation, on: nil) # :nodoc:
|
|
15
|
-
manager = klass.arel_table.left_join_lateral(relation)
|
|
16
|
-
manager.on(on) if on
|
|
17
|
-
|
|
18
|
-
self.joins_values |= [manager.join_sources.first]
|
|
19
|
-
self
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module ActiveRecord
|
|
6
|
-
module LeftUnnest
|
|
7
|
-
def left_unnest(column, as: column.singularize)
|
|
8
|
-
raise(ArgumentError, "The method .left_unnest() must contain arguments.") if column.nil?
|
|
9
|
-
|
|
10
|
-
spawn.unnest(column, as: as, type: :left_join_lateral)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module ActiveRecord
|
|
6
|
-
module Unnest
|
|
7
|
-
def unnest(column, as: column.singularize, type: :left_join_lateral)
|
|
8
|
-
raise(ArgumentError, "The method .unnest() must contain arguments.") if column.nil?
|
|
9
|
-
|
|
10
|
-
spawn.unnest!(column, as, type)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def unnest!(column, name, type) # :nodoc:
|
|
14
|
-
function = ::Arel::Nodes::NamedFunction.new("unnest", [klass.arel_table[column]]).as(name)
|
|
15
|
-
spawn.send("#{type}!", function, **({ on: ::Arel.sql("TRUE") } if type == :left_join_lateral))
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module ActiveRecord
|
|
6
|
-
module WhereChain
|
|
7
|
-
%i[
|
|
8
|
-
lt lteq gt gteq
|
|
9
|
-
between not_between in not_in like
|
|
10
|
-
ilike not_like not_ilike
|
|
11
|
-
like_all ilike_all not_like_all not_ilike_all
|
|
12
|
-
like_any ilike_any not_like_any not_ilike_any
|
|
13
|
-
has_bits not_has_bits
|
|
14
|
-
].each do |method|
|
|
15
|
-
define_method(method) do |conditions|
|
|
16
|
-
build(conditions, method)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
alias lte lteq
|
|
21
|
-
alias gte gteq
|
|
22
|
-
|
|
23
|
-
# https://www.postgresql.org/docs/current/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
|
|
24
|
-
# "(?e)" means force use of ERE syntax; see sections 9.7.3.1 and 9.7.3.4.
|
|
25
|
-
def regex(conditions = {}, flags: "e", **kwargs)
|
|
26
|
-
conditions.merge!(kwargs) if conditions.is_a?(::Hash)
|
|
27
|
-
build(conditions, :regex, flags)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def not_regex(conditions = {}, flags: "e", **kwargs)
|
|
31
|
-
conditions.merge!(kwargs) if conditions.is_a?(::Hash)
|
|
32
|
-
build(conditions, :not_regex, flags)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def tsquery(conditions = {}, ts_config: "english", **kwargs)
|
|
36
|
-
conditions.merge!(kwargs) if conditions.is_a?(::Hash)
|
|
37
|
-
build(conditions, :tsquery, ts_config)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
METHODS = {
|
|
41
|
-
lt: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].lt(value) },
|
|
42
|
-
lteq: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].lteq(value) },
|
|
43
|
-
gt: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].gt(value) },
|
|
44
|
-
gteq: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].gteq(value) },
|
|
45
|
-
between: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].between(value) },
|
|
46
|
-
not_between: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].not_between(value) },
|
|
47
|
-
in: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].in(value) },
|
|
48
|
-
not_in: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].not_in(value) },
|
|
49
|
-
like: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].matches(value.to_escaped_for_sql_like, ::Arel.sql("E'\\\\'"), true) },
|
|
50
|
-
ilike: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].matches(value.to_escaped_for_sql_like, ::Arel.sql("E'\\\\'"), false) },
|
|
51
|
-
not_like: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].does_not_match(value.to_escaped_for_sql_like, ::Arel.sql("E'\\\\'"), true) },
|
|
52
|
-
not_ilike: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].does_not_match(value.to_escaped_for_sql_like, ::Arel.sql("E'\\\\'"), false) },
|
|
53
|
-
like_all: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].matches_all(value.map(&:to_escaped_for_sql_like), ::Arel.sql("E'\\\\'"), true) },
|
|
54
|
-
ilike_all: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].matches_all(value.map(&:to_escaped_for_sql_like), ::Arel.sql("E'\\\\'"), false) },
|
|
55
|
-
not_like_all: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].does_not_match_all(value.map(&:to_escaped_for_sql_like), ::Arel.sql("E'\\\\'"), true) },
|
|
56
|
-
not_ilike_all: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].does_not_match_all(value.map(&:to_escaped_for_sql_like), ::Arel.sql("E'\\\\'"), false) },
|
|
57
|
-
like_any: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].matches_any(value.map(&:to_escaped_for_sql_like), ::Arel.sql("E'\\\\'"), true) },
|
|
58
|
-
ilike_any: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].matches_any(value.map(&:to_escaped_for_sql_like), ::Arel.sql("E'\\\\'"), false) },
|
|
59
|
-
not_like_any: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].does_not_match_any(value.map(&:to_escaped_for_sql_like), ::Arel.sql("E'\\\\'"), true) },
|
|
60
|
-
not_ilike_any: ->(table_name, column, value) { ::Arel::Table.new(table_name)[column].does_not_match_any(value.map(&:to_escaped_for_sql_like), ::Arel.sql("E'\\\\'"), false) },
|
|
61
|
-
regex: ->(table_name, column, value, flags) { ::Arel::Table.new(table_name)[column].matches_regexp("(?#{flags})#{value.is_a?(Regexp) ? value.source : value}") },
|
|
62
|
-
not_regex: ->(table_name, column, value, flags) { ::Arel::Table.new(table_name)[column].does_not_match_regexp("(?#{flags})#{value.is_a?(Regexp) ? value.source : value}") },
|
|
63
|
-
tsquery: ->(table_name, column, value, ts_config) { ::Arel.sql("to_tsvector(:ts_config, :table) @@ plainto_tsquery(:ts_config, :value)", ts_config: ts_config, value: value, table: ::Arel.sql("#{table_name}.#{column}")) },
|
|
64
|
-
has_bits: ->(table_name, column, value) { ::Arel.sql("(#{table_name}.#{column} & #{::Arel::Nodes.build_quoted(value).to_sql}) = #{::Arel::Nodes.build_quoted(value).to_sql}") },
|
|
65
|
-
not_has_bits: ->(table_name, column, value) { ::Arel.sql("(#{table_name}.#{column} & #{::Arel::Nodes.build_quoted(value).to_sql}) != #{::Arel::Nodes.build_quoted(value).to_sql}") },
|
|
66
|
-
}.freeze
|
|
67
|
-
|
|
68
|
-
private
|
|
69
|
-
|
|
70
|
-
def build(conditions, method, *extra)
|
|
71
|
-
model = @scope.klass
|
|
72
|
-
|
|
73
|
-
parsed_conditions = normalize_conditions(conditions, model)
|
|
74
|
-
|
|
75
|
-
arel_conditions = parsed_conditions.map do |(table_name, column), value|
|
|
76
|
-
METHODS.fetch(method).call(table_name, column, value, *extra)
|
|
77
|
-
end.reduce(:and)
|
|
78
|
-
|
|
79
|
-
@scope.where(arel_conditions)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def normalize_conditions(conditions, model, table_name = nil)
|
|
83
|
-
pairs = []
|
|
84
|
-
|
|
85
|
-
conditions.each do |key, value|
|
|
86
|
-
case key
|
|
87
|
-
when ::String, ::Symbol
|
|
88
|
-
key = key.to_s
|
|
89
|
-
if value.is_a?(::Hash)
|
|
90
|
-
pairs.concat(normalize_conditions(value, model, key))
|
|
91
|
-
elsif key.include?(".")
|
|
92
|
-
table, col = key.split(".", 2)
|
|
93
|
-
pairs << [[table, col], value]
|
|
94
|
-
else
|
|
95
|
-
pairs << [[table_name || model.table_name, key], value]
|
|
96
|
-
end
|
|
97
|
-
else
|
|
98
|
-
raise(ArgumentError, "Unsupported key type: #{key.class}")
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
pairs
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require("arel")
|
|
4
|
-
|
|
5
|
-
module YiffSpace
|
|
6
|
-
module Extensions
|
|
7
|
-
module Arel
|
|
8
|
-
module Nodes
|
|
9
|
-
class CrossJoinLateral < ::Arel::Nodes::Join
|
|
10
|
-
def initialize(left, right = nil)
|
|
11
|
-
super
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require("arel")
|
|
4
|
-
|
|
5
|
-
module YiffSpace
|
|
6
|
-
module Extensions
|
|
7
|
-
module Arel
|
|
8
|
-
module Nodes
|
|
9
|
-
class LeftJoinLateral < ::Arel::Nodes::Join
|
|
10
|
-
def initialize(left, right = nil)
|
|
11
|
-
super
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module Arel
|
|
6
|
-
module Table
|
|
7
|
-
module CrossJoinLateral
|
|
8
|
-
def cross_join_lateral(relation)
|
|
9
|
-
join(relation, ::Arel::Nodes::CrossJoinLateral)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module Arel
|
|
6
|
-
module Visitors
|
|
7
|
-
module PostgreSQL
|
|
8
|
-
module CrossJoinLateral
|
|
9
|
-
# noinspection RubyInstanceMethodNamingConvention
|
|
10
|
-
def visit_YiffSpace_Extensions_Arel_Nodes_CrossJoinLateral(o, collector)
|
|
11
|
-
collector << "CROSS JOIN LATERAL "
|
|
12
|
-
visit(o.left, collector)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module Arel
|
|
6
|
-
module Visitors
|
|
7
|
-
module PostgreSQL
|
|
8
|
-
module LeftJoinLateral
|
|
9
|
-
# noinspection RubyInstanceMethodNamingConvention
|
|
10
|
-
def visit_YiffSpace_Extensions_Arel_Nodes_LeftJoinLateral(o, collector)
|
|
11
|
-
collector << "LEFT JOIN LATERAL "
|
|
12
|
-
visit(o.left, collector)
|
|
13
|
-
return unless o.right
|
|
14
|
-
|
|
15
|
-
collector << " ON "
|
|
16
|
-
visit(o.right.expr, collector)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require("active_support/core_ext/module/attribute_accessors")
|
|
4
|
-
|
|
5
|
-
module YiffSpace
|
|
6
|
-
module Extensions
|
|
7
|
-
module Enumerable
|
|
8
|
-
module Parallel
|
|
9
|
-
mattr_accessor(:usable)
|
|
10
|
-
# Like `#each`, but perform the block on each item in parallel. Note that items aren't processed in order, so things
|
|
11
|
-
# like `parallel_each.map` that rely on ordering won't work.
|
|
12
|
-
def parallel_each(executor = :io, &)
|
|
13
|
-
return enum_for(:parallel_each, executor) unless block_given?
|
|
14
|
-
|
|
15
|
-
parallel_map(executor, &)
|
|
16
|
-
self
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# Like `#map`, but in parallel.
|
|
20
|
-
def parallel_map(executor = :io, &)
|
|
21
|
-
return enum_for(:parallel_map, executor) unless block_given?
|
|
22
|
-
|
|
23
|
-
promises = map do |item|
|
|
24
|
-
Concurrent::Promises.future_on(executor, item, &)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
Concurrent::Promises.zip_futures_on(executor, *promises).value!
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
begin
|
|
35
|
-
require("concurrent-ruby")
|
|
36
|
-
YiffSpace::Extensions::Enumerable::Parallel.usable = true
|
|
37
|
-
rescue LoadError
|
|
38
|
-
YiffSpace::Extensions::Enumerable::Parallel.usable = false
|
|
39
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module Object
|
|
6
|
-
module ToB
|
|
7
|
-
def to_b
|
|
8
|
-
case self
|
|
9
|
-
when ::String
|
|
10
|
-
!match?(/\A(false|f|no|n|off|0)\z/i)
|
|
11
|
-
when ::TrueClass
|
|
12
|
-
true
|
|
13
|
-
when ::FalseClass
|
|
14
|
-
false
|
|
15
|
-
else
|
|
16
|
-
to_s.to_b
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module Object
|
|
6
|
-
module TruthyFalsy
|
|
7
|
-
def truthy?
|
|
8
|
-
case self
|
|
9
|
-
when ::String
|
|
10
|
-
match?(/\A(true|t|yes|y|on|1)\z/i)
|
|
11
|
-
when ::TrueClass
|
|
12
|
-
true
|
|
13
|
-
when ::FalseClass
|
|
14
|
-
false
|
|
15
|
-
else
|
|
16
|
-
to_s.truthy?
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def falsy?
|
|
21
|
-
case self
|
|
22
|
-
when ::String
|
|
23
|
-
match?(/\A(false|f|no|n|off|0)\z/i)
|
|
24
|
-
when ::TrueClass
|
|
25
|
-
false
|
|
26
|
-
when ::FalseClass
|
|
27
|
-
true
|
|
28
|
-
else
|
|
29
|
-
to_s.falsy?
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module YiffSpace
|
|
4
|
-
module Extensions
|
|
5
|
-
module String
|
|
6
|
-
module Sql
|
|
7
|
-
def to_escaped_for_sql_like
|
|
8
|
-
gsub(/%|_|\*|\\\*|\\\\|\\/) do |str|
|
|
9
|
-
case str
|
|
10
|
-
when "%" then '\%'
|
|
11
|
-
when "_" then '\_'
|
|
12
|
-
when "*" then "%"
|
|
13
|
-
when '\*' then "*"
|
|
14
|
-
when "\\\\", "\\" then "\\\\"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|