forest_admin_datasource_mongoid 1.45.1 → 1.45.2
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: de923427287155a0df371496903f860e8889430abf7aa1609bd4bf8f17f30b35
|
|
4
|
+
data.tar.gz: be3514f5c733a9593bbd1ebb4c09200f4567ce38a3dba131e7f91578efe6ad82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 56e621caa5039afe72c1574bbf953621db94c901914d3a3a19c00f68afba0b1b638196f7287d1d3756ad103ba04ad012ff2db66c042919ca083bce8b1b6b554e
|
|
7
|
+
data.tar.gz: 4f87635abaef12140b87e6facaa0eb0fc7af1c6407a50d98cd1bb249977dc723939443fa03b7fe76a57cce249f4d4dc1d48270834428184316442c2f9d1d7cae
|
|
@@ -21,37 +21,44 @@ module ForestAdminDatasourceMongoid
|
|
|
21
21
|
def add_null_values_on_record(record, projection)
|
|
22
22
|
return nil if record.nil?
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
fill_null_values(record, build_null_values_tree(projection))
|
|
25
|
+
end
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
result[field_prefix] ||= nil
|
|
29
|
-
end
|
|
27
|
+
def add_null_values(records, projection)
|
|
28
|
+
return [] if records.empty?
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
tree = build_null_values_tree(projection)
|
|
31
|
+
records.filter_map { |record| fill_null_values(record, tree) }
|
|
32
|
+
end
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
prefix_with_colon = "#{nested_prefix}:"
|
|
35
|
-
child_paths = projection.filter_map do |field|
|
|
36
|
-
field[(nested_prefix.size + 1)..] if field.start_with?(prefix_with_colon)
|
|
37
|
-
end
|
|
34
|
+
private
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
def build_null_values_tree(paths)
|
|
37
|
+
paths.group_by { |path| path.split(':', 2).first }.to_h do |key, key_paths|
|
|
38
|
+
child_paths = key_paths.filter_map { |path| path.split(':', 2)[1] }
|
|
39
|
+
[key, child_paths.empty? ? nil : build_null_values_tree(child_paths)]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
def fill_null_values(record, tree)
|
|
44
|
+
return nil if record.nil?
|
|
45
|
+
|
|
46
|
+
result = record.dup
|
|
47
|
+
|
|
48
|
+
tree.each do |key, sub_tree|
|
|
49
|
+
result[key] ||= nil
|
|
50
|
+
result[key] = fill_nested_null_values(result[key], sub_tree) if sub_tree
|
|
48
51
|
end
|
|
49
52
|
|
|
50
53
|
remove_not_exist_record(result)
|
|
51
54
|
end
|
|
52
55
|
|
|
53
|
-
def
|
|
54
|
-
|
|
56
|
+
def fill_nested_null_values(value, sub_tree)
|
|
57
|
+
case value
|
|
58
|
+
when Array then value.map { |item| item.is_a?(Hash) ? fill_null_values(item, sub_tree) : item }
|
|
59
|
+
when Hash then fill_null_values(value, sub_tree)
|
|
60
|
+
else value
|
|
61
|
+
end
|
|
55
62
|
end
|
|
56
63
|
end
|
|
57
64
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_admin_datasource_mongoid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.45.
|
|
4
|
+
version: 1.45.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthieu
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-10-
|
|
12
|
+
date: 2026-10-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: mongoid
|