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 +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: 3751729665ad36eddcb41f4e994f500e560475c7f7ae96a7f70f2609270572fd
|
4
|
+
data.tar.gz: 48081174198bec227b8b6114fe5cfa35b72c917ad5a95bea4755be32e420cf0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
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
|
}
|