Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeevan-Kishore committed Jun 3, 2024
1 parent 8f0486d commit 6758316
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
6 changes: 3 additions & 3 deletions AmpConfig.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ <h2><span class="attribs"><span class="type-signature"></span></span>AmpConfig</
<p class="tag-source">
<a href="index.js.html" class="button">View Source</a>
<span>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1136">line 1136</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1137">line 1137</a>
</span>
</p>

Expand Down Expand Up @@ -311,7 +311,7 @@ <h5>Parameters:</h5>
<p class="tag-source">
<a href="index.js.html" class="button">View Source</a>
<span>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1155">line 1155</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1156">line 1156</a>
</span>
</p>

Expand Down Expand Up @@ -431,7 +431,7 @@ <h4 class="name" id="asJson">
<p class="tag-source">
<a href="index.js.html" class="button">View Source</a>
<span>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1142">line 1142</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1143">line 1143</a>
</span>
</p>

Expand Down
2 changes: 1 addition & 1 deletion global.html
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ <h5>Parameters:</h5>
<p class="tag-source">
<a href="index.js.html" class="button">View Source</a>
<span>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1124">line 1124</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line1125">line 1125</a>
</span>
</p>

Expand Down
33 changes: 17 additions & 16 deletions index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>index.js</h1>
const { createCache, memoryStore } = require("cache-manager");

const { DEFAULT_REQUEST_TIMEOUT, ENABLE_AXIOS } = require("./constants");
const { CACHE_TIME, MAX_CACHE, ENABLE_TTL_CACHE } = require("./cache-constant");
const { CACHE_TIME, MAX_CACHE, ENABLE_TTL_CACHE, BULK_REQ_TTL_CACHE } = require("./cache-constant");

const memoryStoreInit = memoryStore();
const memoryCache = createCache(memoryStoreInit, {
Expand Down Expand Up @@ -407,8 +407,8 @@ <h1>index.js</h1>
- Cricket `(Level 3)`
- Football `(Level 3)`
- Tennis `(Level 3)`
In the above example with nestedCollectionLimit: {ThreeColGrid: [2, 3, 4]}, Cricket collection will fetch 2 items, Football will fetch 5 items and Tennis will fetch 4 items. (default: defaultNestedLimit || 40)
* @param {Object} options.collectionOfCollectionsIndexes It accepts array of indexes(collection's position) to fetch collection of collection of items when the depth is 1. (Ex: collectionOfCollectionsIndexes: [0, 4]).
In the above example with nestedCollectionLimit: {ThreeColGrid: [2, 3, 4]}, Cricket collection will fetch 2 items, Football will fetch 5 items and Tennis will fetch 4 items. (default: defaultNestedLimit || 40)
* @param {Object} options.collectionOfCollectionsIndexes It accepts array of indexes(collection's position) to fetch collection of collection of items when the depth is 1. (Ex: collectionOfCollectionsIndexes: [0, 4]).
eg:
- Home `(Level 1)`
- Sports Row `(Level 2)`
Expand All @@ -418,10 +418,10 @@ <h1>index.js</h1>
- Movie `(Level 3)`
- Song `(Level 3)`
In the above example if we need to fetch the stories from `Sports Row` child collection we need to pass collectionOfCollectionsIndexes : [0], where 0 is the position of collection Sports Row and stories from Cricket and Football will be fetched
* @param {Object} options.customLayouts It accepts an array of objects to fetch the custom storyLimit and custom nestedCollectionLimit of custom layouts. (Ex: customLayouts: [{layout: "ArrowThreeColGrid", storyLimit: 9}, {layout: "ArrowTwoColTenStories", storyLimit: 2, nestedCollectionLimit: [5,5]}]).
* @return {(Promise&lt;Collection|null>)}
* @see {@link https://developers.quintype.com/swagger/#/collection/get_api_v1_collections__slug_ GET /api/v1/collections/:slug} API documentation for a list of parameters and fields
*/
* @param {Object} options.customLayouts It accepts an array of objects to fetch the custom storyLimit and custom nestedCollectionLimit of custom layouts. (Ex: customLayouts: [{layout: "ArrowThreeColGrid", storyLimit: 9}, {layout: "ArrowTwoColTenStories", storyLimit: 2, nestedCollectionLimit: [5,5]}]).
* @return {(Promise&lt;Collection|null>)}
* @see {@link https://developers.quintype.com/swagger/#/collection/get_api_v1_collections__slug_ GET /api/v1/collections/:slug} API documentation for a list of parameters and fields
*/
static getCollectionBySlug(client, slug, params, options = {}) {
const {
depth = DEFAULT_DEPTH,
Expand Down Expand Up @@ -1120,10 +1120,6 @@ <h1>index.js</h1>

async getInBulk(requests) {
const requestHash = hash(requests);
this._cachedPostBulkLocations[requestHash] =
this._cachedPostBulkLocations[requestHash] ||
(await this._cachedPostBulkGate(requestHash, getBulkLocation.bind(this)));
return this.request(this._cachedPostBulkLocations[requestHash]);

async function getBulkLocation() {
const response = await this.request("/api/v1/bulk-request", {
Expand All @@ -1136,15 +1132,20 @@ <h1>index.js</h1>
simple: false,
resolveWithFullResponse: true
});

if (ENABLE_AXIOS &amp;&amp; response.statusCode === 200 &amp;&amp; response.redirectCount > 0) {
return response.headers["content-location"];
} else if (response.statusCode === 303 &amp;&amp; response.caseless.get("Location")) {
return response.caseless.get("Location");
if (response.statusCode === 303 &amp;&amp; response.caseless.get("Location")) {
const contentLocation = response.caseless.get("Location");
await memoryCache.set(requestHash, contentLocation, BULK_REQ_TTL_CACHE);
return contentLocation;
} else {
throw new Error(`Could Not Convert POST bulk to a get, got status ${response.statusCode}`);
}
}

let cachedRequestHash = await memoryCache.get(requestHash);
if (!cachedRequestHash) {
cachedRequestHash = await getBulkLocation.bind(this)();
}
return this.request(cachedRequestHash);
}

getAmpStoryBySlug(slug) {
Expand Down

0 comments on commit 6758316

Please sign in to comment.