Skip to content

Commit

Permalink
test: decrease batch size and set idleTimeout for Piscina
Browse files Browse the repository at this point in the history
  • Loading branch information
scissorsneedfoodtoo committed Dec 15, 2024
1 parent c16bddf commit df976a3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/_data/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ const fetchFromGhost = require('../../utils/ghost/fetch-from-ghost');
const fetchFromHashnode = require('../../utils/hashnode/fetch-from-hashnode');
const { postsPerPage, siteURL } = require('../../config');
const pingEditorialTeam = require('../../utils/ping-editorial-team');
const idleTimeoutMS = 1 * 60 * 60 * 1000; // 1 hour in milliseconds

const getUniqueList = (arr, key) => [
...new Map(arr.map(item => [item[key], item])).values()
];

const piscinaGhost = new Piscina({
filename: resolve(__dirname, '../../utils/ghost/process-batch')
filename: resolve(__dirname, '../../utils/ghost/process-batch'),
idleTimeout: idleTimeoutMS
});
const piscinaHashnode = new Piscina({
filename: resolve(__dirname, '../../utils/hashnode/process-batch')
filename: resolve(__dirname, '../../utils/hashnode/process-batch'),
idleTimeout: idleTimeoutMS
});

module.exports = async () => {
// Chunk raw Ghost posts and pages and process them in batches
// with a pool of workers to create posts and pages global data
const batchSize = 400;
const batchSize = 300;
const allGhostPosts = await fetchFromGhost('posts');
const allHashnodePosts = await fetchFromHashnode('posts');
const allGhostPages = await fetchFromGhost('pages');
Expand Down

0 comments on commit df976a3

Please sign in to comment.