Skip to content

Instantly share code, notes, and snippets.

@hoangsetup
Created March 26, 2022 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoangsetup/041376f5a2e2057034e5850825908ce5 to your computer and use it in GitHub Desktop.
Save hoangsetup/041376f5a2e2057034e5850825908ce5 to your computer and use it in GitHub Desktop.
import { getLinksByQuery } from './utils/scraper';
import { consume } from './utils/scraper-queue';
import { updateTransactionToDone, updateTransactionToProcessing } from './utils/scraper-transaction';
(async () => {
await consume(async (item) => {
await updateTransactionToProcessing(item.transactionId.toString());
const links = await getLinksByQuery(item.query);
await updateTransactionToDone(
item.transactionId.toString(),
{
query: item.query,
links,
took: (Date.now() - item.transactionId) / 1000,
},
);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment