-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Stats: Reduxify fetching post likes #10361
Conversation
4b69d81
to
fa9975a
Compare
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 great so far. I wasn't too familiar with the posts/<id>/likes
endpoint so I did a bit of digging into the code behind it. The API response also returns ( as I'm sure you know, but putting here for future me 😆 ) found
, i_like
, site_ID
, and post_ID
- the last two items are a bit redundant, but I suppose would be of use in a batch operation. Endpoint documentation here.
Currently, in this state implementation, we are only persisting the likes
array and not the other data. The problem being, the code that powers the likes
array has a hard limit of 90 records on the query - it also appears that the default logic will only return likees that have gravatars via has_gravatar
.
So if we have a post that has > 90 likes, or is liked by users without gravatars, the data we are using in the state tree won't properly reflect the total number of likes. The found
attribute in the response though is a raw COUNT
of all users who have liked a post, no LIMIT
or gravatar requirement.
As such, I think we should probably go ahead and persist the entire response object in the state tree - omitting site_ID
and post_ID
because they are both comprised in the tree. This would allow us to display the proper number of likes on a given post, and potentially a future component that uses this part of the state tree would also want access to i_like
. Do you think that is a good idea too?
} ); | ||
} ); | ||
|
||
it( 'should set site ID to false if request finishes unsuccessfully', () => { |
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.
Should this test description read should set post ID to false if request finishes unsuccessfully
?
Good catch @timmyc I naively supposed all the likes will be returned. |
updated in 4df3ac2 :) |
4df3ac2
to
4735e54
Compare
I rebased the branch, do you think you'll have time to take a look again @timmyc ? |
Looking good now! Thanks for updating that to accommodate all the data. |
4735e54
to
989195f
Compare
As a first step to resolve #10348 I'm creating a
likes
state subtree underposts
.This is also part of #5046
Nothing to test for now.