From 5a035744efb19a5115b6781841776994bded18dd Mon Sep 17 00:00:00 2001 From: Ajan Lal Shrestha Date: Sun, 22 Dec 2019 15:07:09 +0545 Subject: [PATCH] feat(algo): Add simple filter algorithm --- worker/tasks/fetch-github.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/worker/tasks/fetch-github.js b/worker/tasks/fetch-github.js index f57576b..020d80a 100644 --- a/worker/tasks/fetch-github.js +++ b/worker/tasks/fetch-github.js @@ -7,6 +7,16 @@ const setAsync = promisify(client.set).bind(client); const baseURL = 'https://jobs.github.com/positions.json'; +const filterAlgo = ({title}) => { + const jobTitle = title.toLowerCase(); + return !( + jobTitle.includes('senior') || + jobTitle.includes('manager') || + jobTitle.includes('sr.') || + jobTitle.includes('architect') + ); +}; + const fetchGithub = async () => { let resultCount = 1, onPage = 0; @@ -22,6 +32,13 @@ const fetchGithub = async () => { } console.log(`got ${allJobs.length} jobs`); + + // filter algo + const jrJobs = allJobs.filter(filterAlgo); + + console.log(`filtered down to ${jrJobs.length}`); + + // set in redis const successs = await setAsync('github', JSON.stringify(allJobs)); console.log(successs);