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 +4 -4
- data/lib/forest_admin_datasource_active_record/collection.rb +2 -2
- data/lib/forest_admin_datasource_active_record/utils/query.rb +8 -6
- data/lib/forest_admin_datasource_active_record/utils/query_aggregate.rb +2 -2
- data/lib/forest_admin_datasource_active_record/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d52efd7a951587f8f99ecee3c410f48066c639814e7788c6e4aeca8fae3ac15
|
4
|
+
data.tar.gz: 0e6b033f95a8c496cc30622b9210000564410fa14a4c865fafdd6089dd08748b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
19
|
+
query = Utils::Query.new(self, projection, filter)
|
20
20
|
|
21
|
-
query.
|
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
|
41
|
-
group
|
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
|
}
|