marty 0.5.30 → 0.5.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/marty/data_change.rb +34 -29
- data/lib/marty/data_exporter.rb +4 -2
- data/lib/marty/version.rb +1 -1
- data/spec/dummy/public/images/icons +1 -0
- data/spec/dummy/spec/features/javascripts +1 -0
- data/spec/lib/data_importer_spec.rb +0 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 809fc288adf7ea9d369bca2de4f9f8f3df715c94
|
4
|
+
data.tar.gz: cfb16d53db4fec2a753ad86c27f0f8f0830626b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f40763bca3159b187edc5566ddb499545f0be35e50ba613c525f1bb287dab1e5ccd823eddeab1bbd696d71d1313e51de71656575030dce5692f0cc241e2709c9
|
7
|
+
data.tar.gz: 1b4760cd572d56dc4541654c254a58ce77b2d8a73ef1341f1e03ba61d653bce5cd4d2fbe36b2b0958cb2b9c75205e545bede3ba955328010bf6f735fc64ceb95
|
data/lib/marty/data_change.rb
CHANGED
@@ -4,16 +4,20 @@ class Marty::DataChange
|
|
4
4
|
# Some arbitrary limit so we don't allow enormous queries
|
5
5
|
MAX_COUNT = 64000
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
# will break if DataExporter::export_attrs recurses more than 1 level
|
8
|
+
# and a level 2+ child table has a compound mcfly_uniqueness key
|
9
|
+
delorean_fn :changes, sig: [3, 4] do
|
10
|
+
|t0, t1, class_name, ids = nil|
|
9
11
|
|
10
12
|
klass = class_name.constantize
|
11
13
|
|
12
14
|
t0 = Mcfly.normalize_infinity t0
|
13
15
|
t1 = Mcfly.normalize_infinity t1
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
cols_model = Marty::DataConversion.columns(klass)
|
18
|
+
cols_header = Marty::DataExporter.export_headers(class_name.constantize,
|
19
|
+
nil, [])
|
20
|
+
changes = get_changed_data(t0, t1, klass, ids)
|
17
21
|
|
18
22
|
changes.each_with_object({}) do |(group_id, ol), h|
|
19
23
|
h[group_id] = ol.each_with_index.map do |o, i|
|
@@ -38,18 +42,19 @@ class Marty::DataChange
|
|
38
42
|
exp_attrs = Marty::DataExporter.export_attrs(klass, o).flatten(1)
|
39
43
|
|
40
44
|
# assumes cols order is same as that returned by export_attrs
|
41
|
-
profile["attrs"] = cols.each_with_index.map do
|
42
|
-
|c, i|
|
43
|
-
|
44
|
-
{
|
45
|
-
# FIXME: this will not work if the attr is an association
|
46
|
-
# which will requires multiple keys to identify
|
47
|
-
# (e.g. Rule: name & version)
|
48
|
-
"value" => exp_attrs[i],
|
49
|
-
"changed" => prev && (o.send(c.to_sym) != prev.send(c.to_sym)),
|
50
|
-
}
|
51
|
-
end
|
52
45
|
|
46
|
+
profile["attrs"] = cols_model.each_with_index.with_object([]) do
|
47
|
+
|(col, i), a|
|
48
|
+
header_current = cols_header[i]
|
49
|
+
valcount = Array === header_current ? header_current.count : 1
|
50
|
+
changed = o.send(col.to_sym) != prev.send(col.to_sym) if prev
|
51
|
+
valcount.times do
|
52
|
+
a.push({
|
53
|
+
"value" => exp_attrs.shift,
|
54
|
+
"changed" => changed
|
55
|
+
})
|
56
|
+
end
|
57
|
+
end
|
53
58
|
profile
|
54
59
|
end
|
55
60
|
end
|
@@ -90,14 +95,8 @@ class Marty::DataChange
|
|
90
95
|
|
91
96
|
delorean_fn :class_headers, sig: 1 do
|
92
97
|
|class_name|
|
93
|
-
|
94
|
-
|
95
|
-
assoc = Marty::DataConversion.associations klass
|
96
|
-
Marty::DataConversion.columns(klass).map { |c|
|
97
|
-
# strip _id if it's an assoc
|
98
|
-
c = c[0..-4] if assoc[c]
|
99
|
-
I18n.t(c, scope: 'attributes', default: c)
|
100
|
-
}
|
98
|
+
Marty::DataExporter.export_headers(class_name.constantize, nil, []).flatten.
|
99
|
+
map { |f| I18n.t(f, scope: 'attributes', default: f) }
|
101
100
|
end
|
102
101
|
|
103
102
|
delorean_fn :user_name, sig: 1 do
|
@@ -161,19 +160,25 @@ class Marty::DataChange
|
|
161
160
|
}
|
162
161
|
end
|
163
162
|
|
164
|
-
def self.get_changed_data(t0, t1, klass)
|
163
|
+
def self.get_changed_data(t0, t1, klass, ids)
|
165
164
|
# The following test fails when t0/t1 are infinity. ActiveSupport
|
166
165
|
# doesn't know about infinity.
|
167
166
|
# return unless t0 < t1
|
168
167
|
|
169
168
|
change_q = '(obsoleted_dt >= ? AND obsoleted_dt < ?)' +
|
170
|
-
|
169
|
+
' OR (created_dt >= ? AND created_dt < ?)'
|
170
|
+
|
171
|
+
countq = klass.unscoped.where(change_q, t0, t1, t0, t1)
|
172
|
+
dataq = klass.where(change_q, t0, t1, t0, t1)
|
173
|
+
|
174
|
+
if ids
|
175
|
+
countq = countq.where(group_id: ids)
|
176
|
+
dataq = dataq.where(group_id: ids)
|
177
|
+
end
|
171
178
|
|
172
|
-
raise "Change count exceeds limit #{MAX_COUNT}" if
|
173
|
-
klass.unscoped.where(change_q, t0, t1, t0, t1).count > MAX_COUNT
|
179
|
+
raise "Change count exceeds limit #{MAX_COUNT}" if countq.count > MAX_COUNT
|
174
180
|
|
175
|
-
|
176
|
-
order("group_id, created_dt").group_by(&:group_id)
|
181
|
+
dataq.order("group_id, created_dt").group_by(&:group_id)
|
177
182
|
end
|
178
183
|
|
179
184
|
######################################################################
|
data/lib/marty/data_exporter.rb
CHANGED
@@ -89,11 +89,13 @@ class Marty::DataExporter
|
|
89
89
|
|c|
|
90
90
|
|
91
91
|
v = obj.send(c.to_sym)
|
92
|
-
|
93
92
|
type = col_types[c]
|
94
93
|
|
95
94
|
# return [value] if not assoc or nil
|
96
|
-
next [v] if
|
95
|
+
next [v] if !type.is_a?(Hash)
|
96
|
+
|
97
|
+
# no child row, return nils for each field
|
98
|
+
next [nil]*type[:assoc_keys].count if v.nil?
|
97
99
|
|
98
100
|
assoc_keys = type[:assoc_keys]
|
99
101
|
assoc_class = type[:assoc_class]
|
data/lib/marty/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
../extjs/icons/
|
@@ -0,0 +1 @@
|
|
1
|
+
../../../features/javascripts/
|
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: 0.5.
|
4
|
+
version: 0.5.31
|
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: 2016-02-
|
17
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|
@@ -523,8 +523,10 @@ files:
|
|
523
523
|
- spec/dummy/public/icons/user_delete.png
|
524
524
|
- spec/dummy/public/icons/user_edit.png
|
525
525
|
- spec/dummy/public/icons/wrench.png
|
526
|
+
- spec/dummy/public/images/icons
|
526
527
|
- spec/dummy/script/delayed_job
|
527
528
|
- spec/dummy/script/rails
|
529
|
+
- spec/dummy/spec/features/javascripts
|
528
530
|
- spec/dummy/tmp/.gitkeep
|
529
531
|
- spec/features/javascripts/job_dashboard_live_search.js.coffee
|
530
532
|
- spec/features/javascripts/login.js.coffee
|
@@ -571,9 +573,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
571
573
|
version: '0'
|
572
574
|
requirements: []
|
573
575
|
rubyforge_project:
|
574
|
-
rubygems_version: 2.
|
576
|
+
rubygems_version: 2.5.1
|
575
577
|
signing_key:
|
576
578
|
specification_version: 4
|
577
579
|
summary: A framework for working with versioned data
|
578
580
|
test_files: []
|
579
|
-
has_rdoc:
|