mincer 0.2.14 → 0.2.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mincer/processors/pg_json_dumper/processor.rb +11 -5
- data/lib/mincer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f22e8f584ffd32b05cbf70b9e8dd5fe41ed7e9ba
|
4
|
+
data.tar.gz: 356141e6b9aedfcd17932f0e7384373e44dbd5e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94af085a7d14e719218f240ff468200ed742074f68622d9e8ebda69ef3b6f3493fc3e73fc0949d649dd05296581a2c9f76f760651f803266d0ab140bf4fd1e58
|
7
|
+
data.tar.gz: 07d17eddcc5e834a27211fec0702b29e3c3daad2af2ec672cc37192d48d18fdfb1915f11177f7d602af0b18639c34dbc0b7ef11edb06990589b0cc84cea7fb04
|
@@ -30,7 +30,7 @@ module Mincer
|
|
30
30
|
|
31
31
|
def json_query
|
32
32
|
if @options[:root]
|
33
|
-
json_query_with_root(@options[:root])
|
33
|
+
json_query_with_root(@options[:root], @options[:meta])
|
34
34
|
else
|
35
35
|
basic_json_query
|
36
36
|
end
|
@@ -41,17 +41,23 @@ module Mincer
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# Query for basic json generation. Ex: [{'id': 1}, {...}]
|
44
|
-
def basic_json_query(root = 'json')
|
44
|
+
def basic_json_query(root = 'json', meta = false)
|
45
|
+
meta_sql = if meta
|
46
|
+
", #{@mincer.total_pages} AS total_pages, #{@mincer.total_count} AS total_count, #{@mincer.current_page} AS current_page, #{@mincer.limit_value} AS per_page"
|
47
|
+
else
|
48
|
+
''
|
49
|
+
end
|
45
50
|
<<-SQL
|
46
|
-
SELECT COALESCE(array_to_json(array_agg(row_to_json(subq))), '[]') AS #{root}
|
51
|
+
SELECT COALESCE(array_to_json(array_agg(row_to_json(subq))), '[]') AS #{root} #{meta_sql}
|
47
52
|
FROM (#{base_sql}) as subq
|
48
53
|
SQL
|
49
54
|
end
|
50
55
|
|
51
56
|
# Generates json with root. Ex: If root = 'items' resulting json will be { 'items' => [...] }
|
52
|
-
|
57
|
+
# When `meta` passed will add pagination data(Experimental!!!)
|
58
|
+
def json_query_with_root(root, meta)
|
53
59
|
<<-SQL
|
54
|
-
SELECT row_to_json(t) as json FROM ( #{basic_json_query(root)} ) as t
|
60
|
+
SELECT row_to_json(t) as json FROM ( #{basic_json_query(root, meta)} ) as t
|
55
61
|
SQL
|
56
62
|
end
|
57
63
|
|
data/lib/mincer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mincer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Krasinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.
|
199
|
+
rubygems_version: 2.4.5.1
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: ActiveRecord::Relation wrapper for pagination, order, json, search, cache_digest
|