-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: implemented last fetched time of content-types to reduce subsequent build times #116
base: develop-archived
Are you sure you want to change the base?
fix: implemented last fetched time of content-types to reduce subsequent build times #116
Conversation
contenttype-data.js
Outdated
}; | ||
query.query.uid = { | ||
$in: config.contentTypes | ||
}; // const queryParams = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment if not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
contenttype-data.js
Outdated
$in: referredContentTypesList | ||
} | ||
}); | ||
// query.query = JSON.stringify({ uid: { $in: referredContentTypesList } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment if not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @abhishek305
contenttype-data.js
Outdated
}; | ||
query.query.uid = { | ||
$nin: config.excludeContentTypes | ||
}; // const queryParams = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment if not required
try { | ||
config.cdn = config.cdn ? config.cdn : 'https://cdn.contentstack.io/v3'; | ||
const typePrefix = config.type_prefix || 'Contentstack'; | ||
|
||
const lastFetchedTimeCacheKey = `${typePrefix.toLowerCase()}-content-type-fetch-time-${config.api_key}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making your own key each time, what about a function that returns a key?
const getCacheKey = (name, config) => `${config.type_prefix ?? 'Contentstack'}-${name}-${config.api_key}`;
The benefit here is when you want to update the structure (for example i dont think api key is enough in a cache key, due to #117.) it's updated in a single place.
|
||
let lastFetchedTime = await cache.get(lastFetchedTimeCacheKey); | ||
if (!lastFetchedTime) { | ||
lastFetchedTime = (new Date(null)).toISOString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why null
here but empty on L69?
Implements caching of last fetched content-types time, to reduce the subsequent build times.