alchemy-json_api 0.24.0 → 0.25.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b099850c244a74a544ab7d649f40faee72d021abee257d55ae9061e55c594dfd
|
4
|
+
data.tar.gz: '029e828a551ab68cdc8d1e48d26135ddc43bda3c3aca7565012ed55e40b1f1f8'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9f1c8b7b5e8996ea8edc83d30aecb780d5ff782530f09e8aaf43fc2a38b01e34867e79fc52bac2ecb4be6e5cc5b6ce6cbd2b478fa1d294574d56ebebfe4cd2c
|
7
|
+
data.tar.gz: 4f7efea149006aad79e341939bfa946fa5e87939315eefdfff8ef22f3e4d83b4f9b9a480b4ba058497b1a8f85c3729a2453fd956dff9570debbe384ccfb846cb
|
@@ -10,15 +10,10 @@ module Alchemy
|
|
10
10
|
|
11
11
|
jsonapi_filter(page_scope, allowed) do |filtered_pages|
|
12
12
|
@pages = filtered_pages.result
|
13
|
-
if
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
filtered_pages = filtered.result.map { |page| api_page(page) }
|
18
|
-
jsonapi_paginate(filtered_pages) do |paginated|
|
19
|
-
render jsonapi: paginated
|
20
|
-
end
|
21
|
-
end
|
13
|
+
if !@pages.all?(&:cache_page?)
|
14
|
+
render_pages_json(allowed) && return
|
15
|
+
elsif stale?(last_modified: @pages.maximum(:published_at), etag: @pages.max_by(&:cache_key)&.cache_key)
|
16
|
+
render_pages_json(allowed)
|
22
17
|
end
|
23
18
|
end
|
24
19
|
|
@@ -26,6 +21,10 @@ module Alchemy
|
|
26
21
|
end
|
27
22
|
|
28
23
|
def show
|
24
|
+
if !@page.cache_page?
|
25
|
+
render(jsonapi: api_page(load_page)) && return
|
26
|
+
end
|
27
|
+
|
29
28
|
if stale?(last_modified: last_modified_for(@page), etag: @page.cache_key)
|
30
29
|
# Only load page with all includes when browser cache is stale
|
31
30
|
render jsonapi: api_page(load_page)
|
@@ -36,6 +35,17 @@ module Alchemy
|
|
36
35
|
|
37
36
|
private
|
38
37
|
|
38
|
+
def render_pages_json(allowed)
|
39
|
+
# Only load pages with all includes when browser cache is stale
|
40
|
+
jsonapi_filter(page_scope_with_includes, allowed) do |filtered|
|
41
|
+
# decorate with our page model that has a eager loaded elements collection
|
42
|
+
filtered_pages = filtered.result.map { |page| api_page(page) }
|
43
|
+
jsonapi_paginate(filtered_pages) do |paginated|
|
44
|
+
render jsonapi: paginated
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
39
49
|
def cache_duration
|
40
50
|
ENV.fetch("ALCHEMY_JSON_API_CACHE_DURATION", 3).to_i.hours
|
41
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy-json_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Meyerhoff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
193
|
+
rubygems_version: 3.1.6
|
194
194
|
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: A JSONAPI compliant API for AlchemyCMS
|