Skip to content

Commit

Permalink
Revert files to master
Browse files Browse the repository at this point in the history
  • Loading branch information
TJ Simons committed Mar 27, 2018
1 parent fd277de commit 3a3b569
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 129 deletions.
4 changes: 0 additions & 4 deletions packages/gatsby-source-wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ plugins: [
sourceUrl: "https://source-url.com",
replacementUrl: "https://replacement-url.com",
},
// How many requests should be sent out simultaneously.
// Lower this number if your blog is on a server with
// limitted resources.
concurrentRequests: 50
},
},
];
Expand Down
49 changes: 0 additions & 49 deletions packages/gatsby-source-wordpress/src/__tests__/request-in-queue.js

This file was deleted.

29 changes: 13 additions & 16 deletions packages/gatsby-source-wordpress/src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const axios = require(`axios`)
const _ = require(`lodash`)
const colorized = require(`./output-color`)
const httpExceptionHandler = require(`./http-exception-handler`)
const requestInQueue = require(`./request-in-queue`)

/**
* High-level function to coordinate fetching data from a WordPress
Expand All @@ -19,7 +18,6 @@ async function fetch({
baseUrl,
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 @@ -129,7 +127,6 @@ async function fetch({
_hostingWPCOM,
_auth,
_accessToken,
concurrentRequests,
})
)
if (_verbose) console.log(``)
Expand Down Expand Up @@ -188,7 +185,6 @@ async function fetchData({
_hostingWPCOM,
_auth,
_accessToken,
concurrentRequests,
}) {
const type = route.type
const url = route.url
Expand All @@ -204,7 +200,7 @@ async function fetchData({
if (_verbose) console.time(`Fetching the ${type} took`)

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

Expand Down Expand Up @@ -267,7 +263,7 @@ async function fetchData({
* @returns
*/
async function getPages(
{ url, _perPage, _hostingWPCOM, _auth, _accessToken, _verbose, concurrentRequests },
{ url, _perPage, _hostingWPCOM, _auth, _accessToken, _verbose },
page = 1
) {
try {
Expand Down Expand Up @@ -317,18 +313,18 @@ async function getPages(
}

// We got page 1, now we want pages 2 through totalPages
const pageOptions = _.range(2, totalPages + 1).map(getPage => getOptions(getPage))

// using batchSize instead of concurrent for less overhead from better-queue
// the lib doesn't utilize cluster/child_process, so there isn't real concurrency
const pages = await requestInQueue(pageOptions, { batchSize: concurrentRequests })

const pageData = pages.map(page => page.data)
pageData.forEach(list => {
result = result.concat(list)
const requests = _.range(2, totalPages + 1).map(getPage => {
const options = getOptions(getPage)
return axios(options)
})

return result
return Promise.all(requests).then(pages => {
const data = pages.map(page => page.data)
data.forEach(list => {
result = result.concat(list)
})
return result
})
} catch (e) {
return httpExceptionHandler(e)
}
Expand All @@ -353,6 +349,7 @@ function getValidRoutes({
refactoredEntityTypes,
}) {
let validRoutes = []

for (let key of Object.keys(allRoutes.data.routes)) {
if (_verbose) console.log(`Route discovered :`, key)
let route = allRoutes.data.routes[key]
Expand Down
2 changes: 0 additions & 2 deletions packages/gatsby-source-wordpress/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ exports.sourceNodes = async (
verboseOutput,
perPage = 100,
searchAndReplaceContentUrls = {},
concurrentRequests = 10,
}
) => {
const { createNode } = boundActionCreators
Expand All @@ -49,7 +48,6 @@ exports.sourceNodes = async (
_perPage,
typePrefix,
refactoredEntityTypes,
concurrentRequests,
})

// Normalize data & create nodes
Expand Down
58 changes: 0 additions & 58 deletions packages/gatsby-source-wordpress/src/request-in-queue.js

This file was deleted.

0 comments on commit 3a3b569

Please sign in to comment.