Skip to content

Commit

Permalink
fix(hackernews): null check for item
Browse files Browse the repository at this point in the history
  • Loading branch information
aldy505 committed Nov 15, 2023
1 parent be20f63 commit 5cbefa5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/services/hackernews/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ export async function run(context) {

// eslint-disable-next-line no-await-in-loop
const item = await getItem(story);
if (item == null) continue;

Check failure on line 47 in src/services/hackernews/index.js

View workflow job for this annotation

GitHub Actions / Check

Expected '===' and instead saw '=='

Check failure on line 47 in src/services/hackernews/index.js

View workflow job for this annotation

GitHub Actions / Check

Expected '===' and instead saw '=='
// We only want stories. Not job, comment, or poll
if (item?.type !== "story") continue;
if (item.type !== "story") continue;
// We only want stories that's high in rating
if (item?.score < 100) continue;
if (item.score != null && item.score < 100) continue;

Check failure on line 51 in src/services/hackernews/index.js

View workflow job for this annotation

GitHub Actions / Check

Expected '!==' and instead saw '!='

Check failure on line 51 in src/services/hackernews/index.js

View workflow job for this annotation

GitHub Actions / Check

Expected '!==' and instead saw '!='
// It's useless if it's dead.
if (item?.dead) continue;
if (item.dead) continue;
// We don't want old stories to come up. Limit this to last 24 hours.
if (item?.time && (item.time * 1000) < last24Hours.getTime()) continue;
if (item.time != null && (item.time * 1000) < last24Hours.getTime()) continue;

Check failure on line 55 in src/services/hackernews/index.js

View workflow job for this annotation

GitHub Actions / Check

Expected '!==' and instead saw '!='

Check failure on line 55 in src/services/hackernews/index.js

View workflow job for this annotation

GitHub Actions / Check

Expected '!==' and instead saw '!='

resultingStories.push(item);
}
Expand Down

0 comments on commit 5cbefa5

Please sign in to comment.