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

Fix #260 implement addPost and getPost method #332

Closed
wants to merge 2 commits into from

Conversation

KarlaChen
Copy link
Contributor

@KarlaChen KarlaChen commented Nov 23, 2019

Added addPost() function using guid as unique key for each post and store posts as sorted set by published date.
Added getPost() by guid and getPosts() by range of dates.
Added test for testing above mentioned functions.

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good! Thanks for all your work so far. I left some comments to address, but this is already in great shape.

src/storage.js Outdated Show resolved Hide resolved
src/storage.js Outdated Show resolved Hide resolved
src/storage.js Outdated Show resolved Hide resolved
src/storage.js Outdated Show resolved Hide resolved
src/storage.js Outdated Show resolved Hide resolved
src/storage.js Outdated Show resolved Hide resolved
src/storage.js Outdated Show resolved Hide resolved
src/storage.js Outdated Show resolved Hide resolved
src/storage.js Outdated
return postId;
},

getPosts: () => redis.zrangebyscore(POSTS, 0, +Infinity),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Either in this PR, or in a follow-up, we can support paging here, by allowing the caller to pass arguments to specify which elements in the set to get. That way they can request a portion vs. everything.

@humphd
Copy link
Contributor

humphd commented Nov 26, 2019

That failure is #343, not related to your changes.

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a test that checks to make sure that the properties of a Post are the same when you get them back out of Redis. Right now we are only checking the guid in the set, but we should also have a test that gets the Post back out of Redis based on a guid and checks that all the fields match what we expect.

This is looking good otherwise.

src/storage.js Outdated
'site',
post.site
)
.zadd(POSTS, new Date(post.published).getTime(), post.guid) // sort set by published date as scores
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still worried about post.published here. I think it should already be a Date, and you should just call getTime() on it. cc @jatinAroraGit, who is working on the Post class.

.exec();
},

getPosts: (startDate, endDate) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about startDate and endDate. You could just pass it as Date parameter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @mskuybeda, I think we could pass a Date and get everything between that date and the current date.

Copy link
Contributor

@mskuybeda mskuybeda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change startDate and endDate to Date parameter

@KarlaChen KarlaChen closed this Nov 28, 2019
@KarlaChen KarlaChen deleted the issue-261 branch November 28, 2019 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants