insights_export 0.2.3 → 0.3.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
  SHA1:
3
- metadata.gz: e98d01f8283e0013cf0deb2d300e0a46de25838b
4
- data.tar.gz: 942b09cf743334413456faad9a53dec3666e9c84
3
+ metadata.gz: 4f5e81738b025c008f1d2497d2cc0dcb8d124c42
4
+ data.tar.gz: 0ba893949615be6531003e4d1904e3608552f034
5
5
  SHA512:
6
- metadata.gz: 663618afbb6a0ef01aa5f6926397bf4a732e6fa551802c8bf55f054a681409d61c30c39f8c567529349d5f132ea554f8b4fd0b090acc4790cd226bb5e7366b65
7
- data.tar.gz: da7917ef0e8bbfa585934080ac41256bbdb293fb79fedcb9a9cb7327eb2f01e6d0aeb8bc6fb085ae5ab2039e6fabf2429b7476031d678ec7aa311e400a0203c2
6
+ metadata.gz: aacf1cf4ad557cb8b514d1fabbf99c81cc4ab56fdc235595502dc727a753d5b046b983473a01b52623820bf9b3ba925175e97f46d3fbe286088cc45280d806c4
7
+ data.tar.gz: 32db48cea7412fee70fd7ffda62d6976807d904477f544392da69843baef643e61633c5a2b1cc2309e3ede75cb171873386828cd0672ae8b44d4aec697c24a84
@@ -25,8 +25,20 @@ module InsightsExport
25
25
  model_structure.each do |key, value|
26
26
  if key == 'custom'
27
27
  next
28
- elsif key == 'columns' || key == 'aggregate'
28
+ elsif key == 'columns' || key == 'links'
29
29
  output[model_name][key] ||= {}
30
+
31
+ # don't merge if 'links' uses the old { links: { incoming: {}, outgoing: {} } } structure.
32
+ # just replace then with the new { links: {} } structure
33
+ # TODO: remove this in the future
34
+ if key == 'links'
35
+ existing_hash_keys = output[model_name][key].keys.map(&:to_s).sort
36
+ if existing_hash_keys == %w(incoming outgoing)
37
+ output[model_name][key] = value
38
+ next
39
+ end
40
+ end
41
+
30
42
  value.each do |value_key, value_value|
31
43
  existing = output[model_name][key][value_key]
32
44
  if existing != false
@@ -114,10 +126,7 @@ module InsightsExport
114
126
  [key.to_sym, obj]
115
127
  end.to_h,
116
128
  custom: {},
117
- links: {
118
- incoming: {},
119
- outgoing: {}
120
- }
129
+ links: {}
121
130
  }
122
131
 
123
132
  model.reflections.each do |association_name, reflection|
@@ -132,7 +141,7 @@ module InsightsExport
132
141
  # reflection.association_primary_key # id
133
142
 
134
143
  model_structure[:columns].delete(reflection.foreign_key.to_sym)
135
- model_structure[:links][:outgoing][association_name] = {
144
+ model_structure[:links][association_name] = {
136
145
  model: reflection_class,
137
146
  model_key: reflection.association_primary_key,
138
147
  my_key: reflection.foreign_key
@@ -143,7 +152,7 @@ module InsightsExport
143
152
  next
144
153
  end
145
154
 
146
- model_structure[:links][:incoming][association_name] = {
155
+ model_structure[:links][association_name] = {
147
156
  model: reflection_class,
148
157
  model_key: reflection.foreign_key,
149
158
  my_key: reflection.association_primary_key
@@ -1,3 +1,3 @@
1
1
  module InsightsExport
2
- VERSION = '0.2.3'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insights_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marius Andra