forest_admin_datasource_active_record 1.0.0.pre.beta.48 → 1.0.0.pre.beta.49

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17839fc311e520887e9351529169cde07e712f063c8c9d0c2d41d03f8a7d2775
4
- data.tar.gz: aa33f350dc3d1b65cfd70daecc511a7dc5a729b55e745c2aa57893a4452acd89
3
+ metadata.gz: 3751729665ad36eddcb41f4e994f500e560475c7f7ae96a7f70f2609270572fd
4
+ data.tar.gz: 48081174198bec227b8b6114fe5cfa35b72c917ad5a95bea4755be32e420cf0f
5
5
  SHA512:
6
- metadata.gz: 35ca8d3c35c7fda3a3c9877e19b1510aedb6bb29af91dd4633bfa27404a10c95326045d9d15f4a4e8f0437e2d9c7282d573bd92a657a7622e3213ec514dc2bf3
7
- data.tar.gz: 653e02b6ad2e0b1c0595691209b6ba494d8ab3a62425a1e537e908ff77f421ebe8d0ac134566b711a92e968aed69a019a283b0b766de7edba6e51dc9a89d5047
6
+ metadata.gz: 955a888a7c4fa73370b581a8f78a50b7e2eaf24b65324aded83acc2d195f32449767d7f9a2c75a8b8c02f12f81ddfe30d5e77325edb0868f0616d80d551f4774
7
+ data.tar.gz: 3d2f22d5028b5f7e08e25567d7f6f7975c0e9e657d8b2e2ad43ee3a9adb148117bb7cdaa64cca8132f778d4f74690f6bad8195eb9129c220ff0ab311374cdc92
@@ -16,9 +16,9 @@ module ForestAdminDatasourceActiveRecord
16
16
  end
17
17
 
18
18
  def list(_caller, filter, projection)
19
- query = Utils::Query.new(self, projection, filter).build
19
+ query = Utils::Query.new(self, projection, filter)
20
20
 
21
- query.all.map { |record| Utils::ActiveRecordSerializer.new(record).to_hash }
21
+ query.get.map { |record| Utils::ActiveRecordSerializer.new(record).to_hash }
22
22
  end
23
23
 
24
24
  def aggregate(_caller, filter, aggregation, limit = nil)
@@ -18,9 +18,16 @@ module ForestAdminDatasourceActiveRecord
18
18
  apply_select
19
19
  end
20
20
 
21
+ def get
22
+ build
23
+
24
+ return @query.all if @filter.page.nil?
25
+
26
+ @query.offset(@filter.page.offset).limit(@filter.page.limit)
27
+ end
28
+
21
29
  def apply_filter
22
30
  @query = apply_condition_tree(@filter.condition_tree) unless @filter.condition_tree.nil?
23
- @query = apply_pagination(@filter.page) unless @filter.page.nil?
24
31
  @query = apply_sort(@filter.sort) unless @filter.sort.nil?
25
32
 
26
33
  @query
@@ -92,11 +99,6 @@ module ForestAdminDatasourceActiveRecord
92
99
  "#{@collection.model.table_name}.#{relation_schema.foreign_key}"
93
100
  end
94
101
  end
95
-
96
- # @query = @query.select(query_select.join(', '))
97
- # @query = @query.eager_load(@projection.relations.keys.map(&:to_sym))
98
- # # TODO: replace eager_load by joins because eager_load select ALL columns of relation
99
- # # @query = @query.joins(@projection.relations.keys.map(&:to_sym))
100
102
  end
101
103
 
102
104
  @query
@@ -37,8 +37,8 @@ module ForestAdminDatasourceActiveRecord
37
37
  def compute_result_aggregate(rows)
38
38
  rows.map do |row|
39
39
  {
40
- value: row.send(@operation.to_sym),
41
- group: @aggregation.groups.each_with_object({}) do |group, memo|
40
+ 'value' => row.send(@operation.to_sym),
41
+ 'group' => @aggregation.groups.each_with_object({}) do |group, memo|
42
42
  memo[group[:field]] = row.send(group[:field].to_sym)
43
43
  end
44
44
  }
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceActiveRecord
2
- VERSION = "1.0.0-beta.48"
2
+ VERSION = "1.0.0-beta.49"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_datasource_active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.48
4
+ version: 1.0.0.pre.beta.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu