Skip to content

Commit

Permalink
[gatsby-source-wordpress] renaming concurrentRequests parameter for c…
Browse files Browse the repository at this point in the history
…onsistency

also added doc note for concurrentRequests and fixed bug in getPages call that prevented verbose output
  • Loading branch information
lightstrike committed Mar 28, 2018
1 parent 7b408e9 commit ca31266
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
8 changes: 5 additions & 3 deletions packages/gatsby-source-wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ plugins: [
wpcom_pass: "very-secured-password",
},
// Set verboseOutput to true to display a verbose output on `npm run develop` or `npm run build`
// It can help you debug specific API Endpoints problems
// It can help you debug specific API Endpoints problems.
verboseOutput: false,
// Set how many pages are retrieved per API request
// Set how many pages are retrieved per API request.
perPage: 100,
// Search and Replace Urls across WordPress content
// Search and Replace Urls across WordPress content.
searchAndReplaceContentUrls: {
sourceUrl: "https://source-url.com",
replacementUrl: "https://replacement-url.com",
},
// Set how many simultaneous requests are sent at once.
concurrentRequests: 10,
// Exclude specific routes using glob parameters
// See: https://github.com/isaacs/minimatch
// Example: `["/*/*/comments", "/yoast/**"]` will exclude routes ending in `comments` and
Expand Down
12 changes: 6 additions & 6 deletions packages/gatsby-source-wordpress/src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ async function fetch({
_hostingWPCOM,
_auth,
_perPage,
_concurrentRequests,
_excludedRoutes,
typePrefix,
refactoredEntityTypes,
concurrentRequests,
}) {
// If the site is hosted on wordpress.com, the API Route differs.
// Same entity types are exposed (excepted for medias and users which need auth)
Expand Down Expand Up @@ -132,7 +132,7 @@ async function fetch({
_hostingWPCOM,
_auth,
_accessToken,
concurrentRequests,
_concurrentRequests,
})
)
if (_verbose) console.log(``)
Expand Down Expand Up @@ -191,7 +191,7 @@ async function fetchData({
_hostingWPCOM,
_auth,
_accessToken,
concurrentRequests,
_concurrentRequests,
}) {
const type = route.type
const url = route.url
Expand All @@ -207,7 +207,7 @@ async function fetchData({
if (_verbose) console.time(`Fetching the ${type} took`)

let routeResponse = await getPages(
{ url, _perPage, _hostingWPCOM, _auth, _accessToken, getPages, concurrentRequests },
{ url, _perPage, _hostingWPCOM, _auth, _accessToken, _verbose, _concurrentRequests },
1
)

Expand Down Expand Up @@ -270,7 +270,7 @@ async function fetchData({
* @returns
*/
async function getPages(
{ url, _perPage, _hostingWPCOM, _auth, _accessToken, _verbose, concurrentRequests },
{ url, _perPage, _hostingWPCOM, _auth, _accessToken, _concurrentRequests, _verbose },
page = 1
) {
try {
Expand Down Expand Up @@ -322,7 +322,7 @@ async function getPages(
// We got page 1, now we want pages 2 through totalPages
const pageOptions = _.range(2, totalPages + 1).map(getPage => getOptions(getPage))

const pages = await requestInQueue(pageOptions, { concurrent: concurrentRequests })
const pages = await requestInQueue(pageOptions, { concurrent: _concurrentRequests })

const pageData = pages.map(page => page.data)
pageData.forEach(list => {
Expand Down
4 changes: 3 additions & 1 deletion packages/gatsby-source-wordpress/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let _useACF = true
let _hostingWPCOM
let _auth
let _perPage
let _concurrentRequests
let _excludedRoutes

exports.sourceNodes = async (
Expand All @@ -40,6 +41,7 @@ exports.sourceNodes = async (
_hostingWPCOM = hostingWPCOM
_auth = auth
_perPage = perPage
_concurrentRequests = concurrentRequests
_excludedRoutes = excludedRoutes

let entities = await fetch({
Expand All @@ -50,10 +52,10 @@ exports.sourceNodes = async (
_hostingWPCOM,
_auth,
_perPage,
_concurrentRequests,
_excludedRoutes,
typePrefix,
refactoredEntityTypes,
concurrentRequests,
})

// Normalize data & create nodes
Expand Down

0 comments on commit ca31266

Please sign in to comment.