forest_admin_datasource_toolkit 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: d6c985d229acb6b65a4abd5f2ff02950c34dea3be259e55e5f7664dba522446e
4
- data.tar.gz: f7725b020b8055117525edf5d6b524692e6910f2d3f9aac2a8e1f61fe54da0f1
3
+ metadata.gz: 9c8434599e736c847c84e7de2d3ca04cae729c97ebbc2b3ab405d6f0024fb8b7
4
+ data.tar.gz: 9d402f94cfa67d24db73eab00de797ceccd26504e0632aeacb2ea2b5bfc3ad07
5
5
  SHA512:
6
- metadata.gz: 5216305ebb9e1158ecd7add263f5c7867f0b72ed83af9a4693e7fc4ac3996769145fbb4318d8690d0a7c02a97862b5dc01a2c1fb3b246e3774aa0f8c25dc98df
7
- data.tar.gz: 82d2aa4db41cb9dbf5e887a8c80aaceec00415cd7a00c6b59033998bf21bd32892c8b80da84ac9321c248c305eab251ff16d117ab537985fc1393c9657586af3
6
+ metadata.gz: 8cd275546a3083d9b370c7a072c8ffeeb35d896b7dd4dcfc357f94687ef7155730e2a472aa241e335c5ce008ad25a70cfe32bca4226890e12339cb9e44b3debb
7
+ data.tar.gz: e3c3221e104febbf6f7eda03db1e0e63ddf49a89f35498d55a086ae4e749fc335c798d7de4183022bb8b75efd7579117c29cbfadd933bd16e1e20978c8783eab
@@ -76,20 +76,14 @@ module ForestAdminDatasourceToolkit
76
76
  end
77
77
 
78
78
  def apply(records)
79
- records.map { |record| re_project(record) }
79
+ tree = ProjectionTree.build(self)
80
+ records.map { |record| tree.re_project(record) }
80
81
  end
81
82
 
82
83
  def re_project(record)
83
- result = nil
84
+ return if record.nil?
84
85
 
85
- if record
86
- record = HashHelper.convert_keys(record, :to_s)
87
- result = {}
88
- columns.each { |column| result[column.to_s] = record[column.to_s] }
89
- relations.each { |relation, projection| result[relation] = projection.re_project(record[relation]) }
90
- end
91
-
92
- result
86
+ ProjectionTree.build(self).re_project(record)
93
87
  end
94
88
 
95
89
  def union(*other_arrays)
@@ -0,0 +1,26 @@
1
+ module ForestAdminDatasourceToolkit
2
+ module Components
3
+ module Query
4
+ ProjectionTree = Struct.new(:columns, :relations) do
5
+ def self.build(projection)
6
+ new(projection.columns.freeze, projection.relations.transform_values { |sub| build(sub) }.freeze).freeze
7
+ end
8
+
9
+ def re_project(record)
10
+ project(record && ForestAdminDatasourceToolkit::Utils::HashHelper.convert_keys(record, :to_s))
11
+ end
12
+
13
+ protected
14
+
15
+ def project(record)
16
+ return unless record
17
+
18
+ result = {}
19
+ columns.each { |column| result[column.to_s] = record[column.to_s] }
20
+ relations.each { |relation, sub_tree| result[relation] = sub_tree.project(record[relation]) }
21
+ result
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceToolkit
2
- VERSION = "1.45.1"
2
+ VERSION = "1.45.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_datasource_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.45.1
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-10 00:00:00.000000000 Z
12
+ date: 2026-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -198,6 +198,7 @@ files:
198
198
  - lib/forest_admin_datasource_toolkit/components/query/page.rb
199
199
  - lib/forest_admin_datasource_toolkit/components/query/projection.rb
200
200
  - lib/forest_admin_datasource_toolkit/components/query/projection_factory.rb
201
+ - lib/forest_admin_datasource_toolkit/components/query/projection_tree.rb
201
202
  - lib/forest_admin_datasource_toolkit/components/query/sort.rb
202
203
  - lib/forest_admin_datasource_toolkit/components/query/sort_utils/sort_factory.rb
203
204
  - lib/forest_admin_datasource_toolkit/datasource.rb