-
Notifications
You must be signed in to change notification settings - Fork 189
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
Conversation
There was a problem hiding this 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
return postId; | ||
}, | ||
|
||
getPosts: () => redis.zrangebyscore(POSTS, 0, +Infinity), |
There was a problem hiding this comment.
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.
That failure is #343, not related to your changes. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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) => |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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
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.