forest_admin_datasource_active_record 1.0.0.pre.beta.48 → 1.0.0.pre.beta.50

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: 3d52efd7a951587f8f99ecee3c410f48066c639814e7788c6e4aeca8fae3ac15
4
+ data.tar.gz: 0e6b033f95a8c496cc30622b9210000564410fa14a4c865fafdd6089dd08748b
5
5
  SHA512:
6
- metadata.gz: 35ca8d3c35c7fda3a3c9877e19b1510aedb6bb29af91dd4633bfa27404a10c95326045d9d15f4a4e8f0437e2d9c7282d573bd92a657a7622e3213ec514dc2bf3
7
- data.tar.gz: 653e02b6ad2e0b1c0595691209b6ba494d8ab3a62425a1e537e908ff77f421ebe8d0ac134566b711a92e968aed69a019a283b0b766de7edba6e51dc9a89d5047
6
+ metadata.gz: bae76960911ff6b477ac8cc5bbf7755f8278803610ddbd022d83ad9a41bc9266a13a54c6ec48569b8dbb76da6b9a254b8a5710d5655f1045503956c3532c4dc4
7
+ data.tar.gz: d74ed35e08f3b54719dd743a0561d40eef7e207b48c696dca6230b01da60776de5ebd4e6b9b72301ecad81aa365e2afc3be19d2986243f06b5db9412570a707e
@@ -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.50"
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.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu