bulk_dependency_eraser 4.1.0 → 4.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10daaabe21acb05d187dcf4c76fae13bd3e3b3aee727be9c6ebd0a315d581b54
|
4
|
+
data.tar.gz: d07c7a1303090c9e9291c19c8b6ec9974f2e9feee050e5962f63522ffd23c623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2152f55aab950c36636bce7e67507ef6a5a27ee7b553a60727796550dc7e2bb489e1bc364beb47e8bce4adf1e0a778b5d5d7011631a77c8734035f85d77f1ded
|
7
|
+
data.tar.gz: 5889cd52acbcde3642db18e60f5958c189e4ecfc8066b635b33f5dfe5eb55810141244828be8043b1c19b403e773fde73dac302de6eabcf9147008e8f6191d85
|
@@ -128,17 +128,17 @@ module BulkDependencyEraser
|
|
128
128
|
def custom_scope_for_query(query)
|
129
129
|
klass = query.klass
|
130
130
|
if opts_c.proc_scopes_per_class_name.key?(klass.name)
|
131
|
-
opts_c.proc_scopes_per_class_name[klass.name].call(query)
|
132
|
-
|
133
|
-
# See if non-class-mapped proc returns a value
|
134
|
-
non_class_name_mapped_query = opts_c.proc_scopes.call(query)
|
135
|
-
if !non_class_name_mapped_query.nil?
|
136
|
-
return non_class_name_mapped_query
|
137
|
-
else
|
138
|
-
# No custom wrapper, return non-effect default
|
139
|
-
return self.class::DEFAULT_KLASS_MAPPED_SCOPE_WRAPPER.call(query)
|
140
|
-
end
|
131
|
+
result = opts_c.proc_scopes_per_class_name[klass.name].call(query)
|
132
|
+
return result unless result.nil?
|
141
133
|
end
|
134
|
+
|
135
|
+
if opts_c.proc_scopes
|
136
|
+
result = opts_c.proc_scopes.call(query)
|
137
|
+
return result unless result.nil?
|
138
|
+
end
|
139
|
+
|
140
|
+
# Could just return query, but don't wnat to break backwards compatiblity
|
141
|
+
return self.class::DEFAULT_KLASS_MAPPED_SCOPE_WRAPPER.call(query)
|
142
142
|
end
|
143
143
|
|
144
144
|
# Create options container
|
@@ -42,13 +42,16 @@ module BulkDependencyEraser
|
|
42
42
|
disable_read_batching: nil,
|
43
43
|
# Applied to all queries. Useful for taking advantage of specific indexes
|
44
44
|
# - not indexed by klass name. Proc would handle the logic for that.
|
45
|
-
# -
|
45
|
+
# - 4th, and lowest, priority of scopes
|
46
46
|
# - accepts rails query as parameter
|
47
47
|
# - return nil if no applicable scope.
|
48
48
|
proc_scopes: self::DEFAULT_SCOPE_WRAPPER,
|
49
49
|
# Applied to all queries. Useful for taking advantage of specific indexes
|
50
|
-
# -
|
50
|
+
# - 3rd highest priority of scopes
|
51
51
|
proc_scopes_per_class_name: {},
|
52
|
+
# Applied to all queries. Useful for taking advantage of specific indexes
|
53
|
+
# - 2nd highest priority of scopes
|
54
|
+
reading_proc_scopes: self::DEFAULT_SCOPE_WRAPPER,
|
52
55
|
# Applied to reading queries
|
53
56
|
# - 1st priority of scopes
|
54
57
|
reading_proc_scopes_per_class_name: {},
|
@@ -146,11 +149,18 @@ module BulkDependencyEraser
|
|
146
149
|
|
147
150
|
def custom_scope_for_query(query)
|
148
151
|
klass = query.klass
|
152
|
+
|
149
153
|
if opts_c.reading_proc_scopes_per_class_name.key?(klass.name)
|
150
|
-
opts_c.reading_proc_scopes_per_class_name[klass.name].call(query)
|
151
|
-
|
152
|
-
|
154
|
+
result = opts_c.reading_proc_scopes_per_class_name[klass.name].call(query)
|
155
|
+
return result unless result.nil?
|
156
|
+
end
|
157
|
+
|
158
|
+
if opts_c.reading_proc_scopes
|
159
|
+
result = opts_c.reading_proc_scopes.call(query)
|
160
|
+
return result unless result.nil?
|
153
161
|
end
|
162
|
+
|
163
|
+
super(query)
|
154
164
|
end
|
155
165
|
|
156
166
|
# @param [ActiveRecord::Relation] query
|
@@ -41,13 +41,16 @@ module BulkDependencyEraser
|
|
41
41
|
disable_delete_batching: nil,
|
42
42
|
# Applied to all queries. Useful for taking advantage of specific indexes
|
43
43
|
# - not indexed by klass name. Proc would handle the logic for that.
|
44
|
-
# -
|
44
|
+
# - 4th, and lowest, priority of scopes
|
45
45
|
# - accepts rails query as parameter
|
46
46
|
# - return nil if no applicable scope.
|
47
47
|
proc_scopes: self::DEFAULT_SCOPE_WRAPPER,
|
48
48
|
# Applied to all queries. Useful for taking advantage of specific indexes
|
49
|
-
# -
|
49
|
+
# - 3rd highest priority of scopes
|
50
50
|
proc_scopes_per_class_name: {},
|
51
|
+
# Applied to all queries. Useful for taking advantage of specific indexes
|
52
|
+
# - 2nd highest priority of scopes
|
53
|
+
deletion_proc_scopes: self::DEFAULT_SCOPE_WRAPPER,
|
51
54
|
# Applied to deletion queries
|
52
55
|
# - 1st priority of scopes
|
53
56
|
deletion_proc_scopes_per_class_name: {},
|
@@ -103,11 +106,18 @@ module BulkDependencyEraser
|
|
103
106
|
|
104
107
|
def custom_scope_for_query(query)
|
105
108
|
klass = query.klass
|
109
|
+
|
106
110
|
if opts_c.deletion_proc_scopes_per_class_name.key?(klass.name)
|
107
|
-
opts_c.deletion_proc_scopes_per_class_name[klass.name].call(query)
|
108
|
-
|
109
|
-
|
111
|
+
result = opts_c.deletion_proc_scopes_per_class_name[klass.name].call(query)
|
112
|
+
return result unless result.nil?
|
113
|
+
end
|
114
|
+
|
115
|
+
if opts_c.deletion_proc_scopes
|
116
|
+
result = opts_c.deletion_proc_scopes.call(query)
|
117
|
+
return result unless result.nil?
|
110
118
|
end
|
119
|
+
|
120
|
+
return super(query)
|
111
121
|
end
|
112
122
|
|
113
123
|
def batch_size
|
@@ -43,13 +43,16 @@ module BulkDependencyEraser
|
|
43
43
|
disable_nullify_batching: nil,
|
44
44
|
# Applied to all queries. Useful for taking advantage of specific indexes
|
45
45
|
# - not indexed by klass name. Proc would handle the logic for that.
|
46
|
-
# -
|
46
|
+
# - 4th, and lowest, priority of scopes
|
47
47
|
# - accepts rails query as parameter
|
48
48
|
# - return nil if no applicable scope.
|
49
49
|
proc_scopes: self::DEFAULT_SCOPE_WRAPPER,
|
50
50
|
# Applied to all queries. Useful for taking advantage of specific indexes
|
51
|
-
# -
|
51
|
+
# - 3rd highest priority of scopes
|
52
52
|
proc_scopes_per_class_name: {},
|
53
|
+
# Applied to all queries. Useful for taking advantage of specific indexes
|
54
|
+
# - 2nd highest priority of scopes
|
55
|
+
nullification_proc_scopes: self::DEFAULT_SCOPE_WRAPPER,
|
53
56
|
# Applied to nullification queries
|
54
57
|
# - 1st priority of scopes
|
55
58
|
nullification_proc_scopes_per_class_name: {},
|
@@ -164,11 +167,18 @@ module BulkDependencyEraser
|
|
164
167
|
|
165
168
|
def custom_scope_for_query(query)
|
166
169
|
klass = query.klass
|
170
|
+
|
167
171
|
if opts_c.nullification_proc_scopes_per_class_name.key?(klass.name)
|
168
|
-
opts_c.nullification_proc_scopes_per_class_name[klass.name].call(query)
|
169
|
-
|
170
|
-
|
172
|
+
result = opts_c.nullification_proc_scopes_per_class_name[klass.name].call(query)
|
173
|
+
return result unless result.nil?
|
174
|
+
end
|
175
|
+
|
176
|
+
if opts_c.nullification_proc_scopes
|
177
|
+
result = opts_c.nullification_proc_scopes.call(query)
|
178
|
+
return result unless result.nil?
|
171
179
|
end
|
180
|
+
|
181
|
+
return super(query)
|
172
182
|
end
|
173
183
|
|
174
184
|
def batch_size
|