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
API - New endpoint to retrieve the articles in the reading list of the authenticated user #10540
Conversation
|
Big fan of this! It looks good at a glance but I'll circle back for a more comprehensive look soon. |
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.
Pulled this down and tested it, works great!!!! Love this feature!
One small suggestion on default per_page size but otherwise LGTM!
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.
Hi @Bhacaz, great start! I have a couple of requests stemmed by the same argument: the reading list is and should be its own resource.
Preamble: the API (whose I stands for interface) doesn't necessarily need to reflect the organization of the code or of database models.
In this regard I think we should promote the "reading list" as its own collective resource: a collection of items. These items appear to be articles but they are indeed reactions. Those reactions have metadata that I believe it should be part of the serialization of the "reading list item" sent to the client.
In the context of the reading list, I think we should send back the date of creation as well.
For this reason I propose the following two changes:
-
the URL should be
/api/readinglist, simple as that :)/api/articles/meis a bit of a patch. In an ideal world we should just have a/api/articles/and check authorization to choose which articles to send. Nesting the reading list under there is a bit odd. -
the serialized JSON should be something like (using pseudo json just to make this quicker :D):
[
{
"type_of": "readinglist",
"created_at": "2020-10-03T04:49:16Z",
"article": {
}
...
}
]article then can be the rendering of the _article partial.
Let me know what you think, thank you!
|
Thanks for the review and the comments.
It's a good idea and if for any reason in the future we want to add some CRUD functions this resource will be at a good and significant place (URL).
I agree, the payload should return some useful information about the reaction: But I have some concern about placing the {
"type_of":"article",
"id":18,
"title":" The Wings of the Dove Inventore recusandae",
"description":"Kickstarter normcore tattooed...",
// Rest of the article attributes
"readinglist": {
"type_of": "readinglist"
"status": "valid"
"created_at": "2020-10-03T04:49:16Z",
}
}But I understand your point, the readinglist is in fact a list of reactions with an article I let you have the last word. 😃 |
|
@Bhacaz I'm imagining the use case which would be to build a list of favorite articles by a user, in theory by building an "hypertexted" API we shouldn't embed the What I'm less convinced about is to embed the full representation of the If we look at the UI version of the reading list you get the following information: The body is not there for example, nor are the stats. What if we adhere to that programmatically? In conclusion:
What do you think? cc @benhalpern and @mstruve as well as they provided feedback earlier |
…nd an embed article
|
Change in 568dd93
|
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.
Thanks! Works well, left a few notes and corrections for the copy!
|
@rhymes Thanks for the corrections, English is not my first language. 😃 If requested, I can squash all commits when the PR will be ready to merge. |
|
@Bhacaz thank you! Don't worry about that, commits will be squashed on merge :) Each PR corresponds to a single commit when we merge them in. |
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 looks like its ready to go, we have a flaky spec that was just fixed in master. Can you update this branch and then we should get a green build and be good to go!
|
6b9751e : Codeclimate found duplicated fragment of code... |
…ist of the authenticated user (forem#10540)

What type of PR is this? (check all applicable)
Description
Add a new endpoint in the DEV API to retrieve the reading list articles for the authenticated user.
GET api/articles/me/readinglistRelated Tickets & Documents
This feature was requested in Issue #6755.
QA Instructions, Screenshots, Recordings
You can try the new API endpoint via a
curlcommand with a valid api-key.curl -H "api-key: API-KEY" http://localhost:3000/api/readinglistAdded tests?
Added to documentation?
What gif best describes this PR or how it makes you feel?