-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
How do I narrow down the reactor's reaction? #237
Comments
Yeah it seems like you should use low-level API to fit your needs. $reacter = $user->getLoveReacter();
$reactant = $post->getLoveReactant();
$userReactionsOnPost = $reacter->reactions()->where('reactant_id', $reactant->getId())->get(); |
@Ajay-Bacancy here is an issue related to your question about stop queue of reaction counter: |
I wrote a new page in documentation with example how to make jobs queue sync: |
Ohhh @antonkomarev I have done the same thing. Maybe in enhancement of we can do something like that where we can pass the reactant in getReactions facade like this But anyways I'm closing the issue you can lable it as question and Thank you so much for the custom job dispatching guide really appreciated. Also very nice library for reaction. I have integrated few days back. Thanks Buddy 🤗 |
Looks good! Thanks for sharing! I will think about your proposal |
@Ajay-Bacancy FYI this code block may work pretty slow in cases when reacter has many reactions, on each new reaction it will become slower: $userreactions = $reacterFacade->getReactions()->where('reactant_id', $reactant->id)->values()->pluck('reaction_type_id'); Here breakdown with explanation: $allUserRactions = $reacterFacade->getReactions(); // Here you collecting all the reactions of the user from the database
$filteredUserReactions = $allUserReactions->where('reactant_id', $reactant->id); // We are iterate through the collection and filter out items
$reactionTypeIds = $filteredUserReactions->values()->pluck('reaction_type_id'); As you can see, filtering operation is doing on the PHP side, not on database side, and this may be critical over time. Instead of getting reactions using ReacterFacade use low-level API and get Reacter model. $reacter = $user->getLoveReacter();
$reactant = $post->getLoveReactant();
$userReactionsOnPost = $reacter->reactions()->where('reactant_id', $reactant->getId())->pluck('reaction_type_id'); Then |
@antonkomarev yeh got your point. Thank you so much buddy 😌❤️ |
@Ajay-Bacancy I've created discussion how to implement this feature on high-level API. Will be glad to receive a feedback there: |
And the first proof of concept: |
@Ajay-Bacancy I've introduced new method to fetch concrete user reactions. It's breaking change since API has been changed. Will be added in next major version release. |
Hey @antonkomarev I have one doubt regarding custom job dispatching.
getting all reaction and passing last added reaction. This will works fine with Increment job but how do I pass reaction instance in decrement job? |
One of the solutions: use events and write your own event listener. Event::listen(
ReactionHasBeenAdded::class,
IncrementAggregates::class,
); |
Here is my setup. for adding reaction on the post. Now I want like which reaction is added by the user on perticular post.
is giving all the reaction made by the user but I want to get reaction with perticular post. Also I want to get the name of the reaction but there is no relationship function is given with ReactionType with reacterFacade.
I tried to debug the package but did not found anything so asking here.
Also How can I stop Queue of Reaction Counter And Reaction Total Count. [NOTE] I want to update data immediately.
The text was updated successfully, but these errors were encountered: