Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feed Worker should store Posts in Redis when done #264

Closed
humphd opened this issue Nov 17, 2019 · 6 comments
Closed

Feed Worker should store Posts in Redis when done #264

humphd opened this issue Nov 17, 2019 · 6 comments
Assignees
Labels
area: back-end area: redis Redis Database related

Comments

@humphd
Copy link
Contributor

humphd commented Nov 17, 2019

Our feed-worker.js currently parses Posts, puts them into an array, and console.logs them.

We need to use the work in #260 and #259, we need to update it so that a Post gets stored in the database. This depends on #260 for the changes to storage.js.

@humphd humphd added area: back-end area: redis Redis Database related labels Nov 17, 2019
@c3ho
Copy link
Contributor

c3ho commented Nov 17, 2019

I can work on this one!

@c3ho c3ho self-assigned this Nov 17, 2019
@humphd
Copy link
Contributor Author

humphd commented Nov 17, 2019

@c3ho can I get you to do 1 Issue at a time? Right now you have 3 assigned to you, and other students will want a piece of the action, too.

@c3ho
Copy link
Contributor

c3ho commented Nov 29, 2019

From @humphd

When we "resolve" in the feed worker (or return if using async), we can get the result back using queue.on('completed', (job, result) => /* result is what you resolved */)

const feedQueue = require('./queue');
const feedParser = require('./parser');
const { logger } = require('../utils/logger');
exports.processor = async function(job) {
  const { url } = job.data;
  logger.info({ url }, 'Processing job');
  let posts;
  try {
    posts = await feedParser(url);
  } catch (err) {
    logger.error({ err, url }, 'feed parser failed to parse url');
    throw err;
  }
  return posts.map(post => ({
    author: post.author,
    date: post.date,
    title: post.title,
    description: post.description,
    postURL: post.link,
  }));
};
exports.start = function() {
  // Start processing jobs from the feed queue...
  logger.info('starting feed queue processing...');
  feedQueue.process(exports.processor);
};

@humphd
Copy link
Contributor Author

humphd commented Dec 2, 2019

@c3ho I'm going to need this fix to land in the next day or so. Are you able to do it that quickly? If not, I'll need to take it from you. Let me know. We could also work on it in class tomorrow.

@c3ho
Copy link
Contributor

c3ho commented Dec 2, 2019

I’ll be able to finish by tomorrow

@humphd
Copy link
Contributor Author

humphd commented Dec 2, 2019

Awesome. Let's plan to work on reviewing and merging this in class in the morning.

c3ho added a commit to c3ho/telescope that referenced this issue Dec 2, 2019
c3ho added a commit to c3ho/telescope that referenced this issue Dec 3, 2019
@humphd humphd closed this as completed in 1ae8759 Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: back-end area: redis Redis Database related
Projects
None yet
Development

No branches or pull requests

2 participants