marty 2.4.6 → 2.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/marty.rb +1 -0
- data/lib/marty/cache_adapters.rb +6 -0
- data/lib/marty/cache_adapters/mcfly_ruby_cache.rb +12 -0
- data/lib/marty/mcfly_model.rb +0 -46
- data/lib/marty/monkey.rb +38 -20
- data/lib/marty/version.rb +1 -1
- data/marty.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b427adbbbc21ea8c9e260999376f86e048cbe2e
|
4
|
+
data.tar.gz: a776a0c78d3280491a4cca50017df92e5d872386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f5002a7ccbbd7011768d3c96bbddb2550924d84c21feac1f4920acace47ab293aaf7f087e67317d638f1a3777236654a5ce660b7c465c7b772c3e3ece813438
|
7
|
+
data.tar.gz: 68206fcb4fdc3de3d65dcc0a824ae62a32ecf8fcc0b90efaf7d9e01a5b6d68990244e84f3eb2254be3099fe55576bd3a336994772ccb4aedd1a8ed80c92e8203
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,7 @@ PATH
|
|
5
5
|
aws-sigv4 (~> 1.0, >= 1.0.2)
|
6
6
|
axlsx (= 3.0.0pre)
|
7
7
|
coderay
|
8
|
-
delorean_lang (~> 0.4.
|
8
|
+
delorean_lang (~> 0.4.8)
|
9
9
|
json-schema
|
10
10
|
mcfly (= 0.0.20)
|
11
11
|
net-ldap (= 0.12.1)
|
@@ -83,7 +83,7 @@ GEM
|
|
83
83
|
coffee-script-source
|
84
84
|
execjs
|
85
85
|
coffee-script-source (1.12.2)
|
86
|
-
concurrent-ruby (1.
|
86
|
+
concurrent-ruby (1.1.4)
|
87
87
|
connection_pool (2.2.1)
|
88
88
|
crass (1.0.3)
|
89
89
|
daemons (1.1.9)
|
@@ -93,7 +93,7 @@ GEM
|
|
93
93
|
delayed_job_active_record (4.1.2)
|
94
94
|
activerecord (>= 3.0, < 5.2)
|
95
95
|
delayed_job (>= 3.0, < 5)
|
96
|
-
delorean_lang (0.4.
|
96
|
+
delorean_lang (0.4.8)
|
97
97
|
activerecord (>= 3.2)
|
98
98
|
treetop (~> 1.5)
|
99
99
|
diff-lcs (1.3)
|
@@ -120,7 +120,7 @@ GEM
|
|
120
120
|
pg (~> 0.17)
|
121
121
|
method_source (0.9.0)
|
122
122
|
mime-types (2.99.3)
|
123
|
-
mimemagic (0.3.
|
123
|
+
mimemagic (0.3.3)
|
124
124
|
mini_mime (1.0.0)
|
125
125
|
mini_portile2 (2.3.0)
|
126
126
|
minitest (5.11.3)
|
data/lib/marty.rb
CHANGED
data/lib/marty/mcfly_model.rb
CHANGED
@@ -6,52 +6,6 @@ module Mcfly::Model
|
|
6
6
|
end
|
7
7
|
|
8
8
|
module ClassMethods
|
9
|
-
def clear_lookup_cache!
|
10
|
-
@LOOKUP_CACHE.clear if @LOOKUP_CACHE
|
11
|
-
end
|
12
|
-
|
13
|
-
# FIXME IDEA: we just make :cache an argument to delorean_fn.
|
14
|
-
# That way, we don't need the cached_ flavors. It'll make all
|
15
|
-
# this code a lot simpler. We should also just add the :private
|
16
|
-
# mechanism here.
|
17
|
-
|
18
|
-
# Implements a VERY HACKY class-based (per process) caching
|
19
|
-
# mechanism for database lookup results. Issues include: cached
|
20
|
-
# values are ActiveRecord objects. Query results can be very
|
21
|
-
# large lists which we count as one item in the cache. Caching
|
22
|
-
# mechanism will result in large processes.
|
23
|
-
def cached_delorean_fn(name, options = {}, &block)
|
24
|
-
@LOOKUP_CACHE ||= {}
|
25
|
-
|
26
|
-
delorean_fn(name, options) do |ts, *args|
|
27
|
-
cache_key = [name, ts] + args.map{ |a|
|
28
|
-
a.is_a?(ActiveRecord::Base) ? a.id : a
|
29
|
-
} unless Mcfly.is_infinity(ts)
|
30
|
-
next @LOOKUP_CACHE[cache_key] if
|
31
|
-
cache_key && @LOOKUP_CACHE.has_key?(cache_key)
|
32
|
-
|
33
|
-
res = block.call(ts, *args)
|
34
|
-
|
35
|
-
if cache_key
|
36
|
-
# Cache has >1000 items, clear out the oldest 200. FIXME:
|
37
|
-
# hard-coded, should be configurable. Cache
|
38
|
-
# size/invalidation should be per lookup and not class.
|
39
|
-
# We're invalidating cache items simply based on age and
|
40
|
-
# not usage. This is faster but not as fair.
|
41
|
-
if @LOOKUP_CACHE.count > 1000
|
42
|
-
@LOOKUP_CACHE.keys[0..200].each{|k| @LOOKUP_CACHE.delete(k)}
|
43
|
-
end
|
44
|
-
@LOOKUP_CACHE[cache_key] = res
|
45
|
-
|
46
|
-
# Since we're caching this object and don't want anyone
|
47
|
-
# changing it. FIXME: ideally should freeze this object
|
48
|
-
# recursively.
|
49
|
-
res.freeze unless res.is_a?(ActiveRecord::Relation)
|
50
|
-
end
|
51
|
-
res
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
9
|
def hash_if_necessary(q, private)
|
56
10
|
!private && q.is_a?(ActiveRecord::Base) ? make_openstruct(q) : q
|
57
11
|
end
|
data/lib/marty/monkey.rb
CHANGED
@@ -189,6 +189,8 @@ end
|
|
189
189
|
|
190
190
|
######################################################################
|
191
191
|
|
192
|
+
require 'marty/cache_adapters'
|
193
|
+
|
192
194
|
class ActiveRecord::Base
|
193
195
|
MCFLY_PT_SIG = [1, 1]
|
194
196
|
|
@@ -224,28 +226,44 @@ end
|
|
224
226
|
|
225
227
|
ar_instances = [ActiveRecord::Relation, ActiveRecord::QueryMethods::WhereChain]
|
226
228
|
|
227
|
-
args_hack = [
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
229
|
+
args_hack = [[Object, nil]]*10
|
230
|
+
|
231
|
+
[[:distinct, args_hack],
|
232
|
+
[:find_by, args_hack],
|
233
|
+
[:group, args_hack],
|
234
|
+
[:joins, args_hack],
|
235
|
+
[:limit, [Integer]],
|
236
|
+
[:not, args_hack],
|
237
|
+
[:order, args_hack],
|
238
|
+
[:pluck, args_hack],
|
239
|
+
[:select, args_hack],
|
240
|
+
[:where, args_hack],
|
241
|
+
[:mcfly_pt, [[Date, Time, ActiveSupport::TimeWithZone, String], [nil, Class]]]
|
242
|
+
].each do |meth, args|
|
243
|
+
::Delorean::Ruby.whitelist.add_method meth do |method|
|
244
|
+
ar_instances.each do |ar|
|
245
|
+
method.called_on ar, with: args
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
::Delorean::Ruby.whitelist.add_method :count do |method|
|
250
|
+
ar_instances.each do |ar|
|
251
|
+
method.called_on ar
|
252
|
+
end
|
253
|
+
end
|
254
|
+
::Delorean::Ruby.whitelist.add_method :lookup_grid_distinct_entry do |method|
|
255
|
+
method.called_on OpenStruct, with: [[Date, Time,
|
256
|
+
ActiveSupport::TimeWithZone, String],
|
257
|
+
Hash]
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
mcfly_cache_adapter = ::Marty::CacheAdapters::McflyRubyCache.new(
|
262
|
+
size_per_class: 1000
|
247
263
|
)
|
248
264
|
|
265
|
+
::Delorean::Cache.adapter = mcfly_cache_adapter
|
266
|
+
|
249
267
|
######################################################################
|
250
268
|
|
251
269
|
module Mcfly::Controller
|
data/lib/marty/version.rb
CHANGED
data/marty.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2019-01-
|
17
|
+
date: 2019-01-10 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|
@@ -64,14 +64,14 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.4.
|
67
|
+
version: 0.4.8
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.4.
|
74
|
+
version: 0.4.8
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: mcfly
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -496,6 +496,8 @@ files:
|
|
496
496
|
- lib/marty.rb
|
497
497
|
- lib/marty/aws/base.rb
|
498
498
|
- lib/marty/aws/request.rb
|
499
|
+
- lib/marty/cache_adapters.rb
|
500
|
+
- lib/marty/cache_adapters/mcfly_ruby_cache.rb
|
499
501
|
- lib/marty/content_handler.rb
|
500
502
|
- lib/marty/data_change.rb
|
501
503
|
- lib/marty/data_conversion.rb
|