Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Commit

Permalink
replaced forEach with for i loop
Browse files Browse the repository at this point in the history
  • Loading branch information
the-robot committed Feb 17, 2020
1 parent 9a620ca commit 4ab558d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/tasks/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ const pullNewsAndBroadcast = async () => {
const news = await getNewsFromRss();
const toBroadcast = [];

news.forEach(async document => {
for (let i=0; i<news.length; i++) {
let document = news[i];
delete document.categories;
const added = await insertNewsIfNotExists(document);
// if added means have not broadcasted, so broadcast
if (added) {
toBroadcast.push(document);
}
});
}
if (toBroadcast.length === 0) {
return;
}
Expand Down

0 comments on commit 4ab558d

Please sign in to comment.