Skip to content

Commit

Permalink
feat: report number of nodes created and time taken when building
Browse files Browse the repository at this point in the history
  • Loading branch information
TommasoAmici committed Oct 24, 2021
1 parent 8addfb1 commit cf33b6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { fetchCollection } from "./index";
const GAME_NODE_TYPE = "BggGame";

export const sourceNodes = async (args: SourceNodesArgs, pluginOptions: ICollectionParams) => {
const activity = args.reporter.activityTimer("gatsby-source-bgg");
activity.start();
const cacheKey = "gatsby-source-bgg";
let sourceData = await args.cache.get(cacheKey);
let sourceData: ICollection[] = await args.cache.get(cacheKey);
if (!sourceData) {
sourceData = await fetchCollection(pluginOptions);
await args.cache.set(cacheKey, sourceData);
Expand All @@ -27,6 +29,8 @@ export const sourceNodes = async (args: SourceNodesArgs, pluginOptions: ICollect
const node: NodeInput = { ...game, ...nodeMeta };
args.actions.createNode(node);
});
activity.setStatus(`Nodes created for ${sourceData.length} games`);
activity.end();
return;
};

Expand Down

0 comments on commit cf33b6a

Please sign in to comment.