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

Commit

Permalink
feat(algo): Add simple filter algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
AjanShrestha committed Dec 22, 2019
1 parent 9a5b183 commit 5a03574
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions worker/tasks/fetch-github.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 5a03574

Please sign in to comment.