I want to show my users that you have received some likes from a specific user.
I have explored the discourse site but I don’t find like’s owener of my likes.
I just find the most_liked_by_users but I want all users not most_liked because each like from that specific user is very valuable and we want to show the number to user to try to get like from him.
I ddn’t find anything here:
https://padpors.com/u/{username}/summary.json
AI-generated summary
The discussion is about finding a way to show users who have liked their posts on a Discourse site. The user Alavi1412 wants to display the number of likes from a specific user, not just the most liked users.
JagWaugh suggested using the https://meta.discourse.org/u/{username}/notifications/likes-received.json endpoint, but Alavi1412 found that it only shows the latest likes, not all likes.
cpradio recommended using the https://meta.discourse.org/user_actions.json?offset=0&username=username&filter=2 endpoint, which can be paginated to retrieve all likes. However, Alavi1412 expressed concerns about the impact on site speed and transfer size.
cpradio suggested that the best approach would be to create a plugin that can cache the data and return it in a single response. Alavi1412 mentioned that they have a plugin, profile widget, and asked for opinions on using AJAX to retrieve the data.
Mittineague provided a SQL query that can be used to retrieve the data, and cpradio suggested that the Staff Notes and Who’s Online plugins could be used as a starting point for creating a custom plugin to achieve the desired functionality.
https://meta.discourse.org/u/{username}/notifications/likes-received.json
Thank You but:
It didn’t show me all likes,
It just shoewed me latest likes.
I want to see all a user’s like’s owenrs, all of them.
You will want to use
https://meta.discourse.org/user_actions.json?offset=0&username=username&filter=2
That will get you page one (30 entries) then you can call page 2 using
https://meta.discourse.org/user_actions.json?offset=30&username=username&filter=2
and so forth.
Does doing this reduce the site’s speed?
How is the effect on the speed for each ajax?
If you are asking if you could theoretically DDOS a site by requesting that information for each user, then the answer is, it depends. There are ratelimits setup by default in Discourse, however, if you tweaked those or are bypassing them, then well, you’re on your own. ![]()
No I didn’t mean that ![]()
The js code run on the user’s browsers may reduce the speed for him and annoy him.
I am asking about the transfer size. Our site’s transfer size is about 2.8 MB and I don’t want to increase the size by inefficient ajax.
I want to reduce the ajax numbers to the lowest number possible
Your best bet is a plugin. As it is incredibly inefficient to approach it using the existing endpoints. As they are meant for lazy loading and not for statistic gathering, which is what you are attempting.
It would be far wiser to create a new response that can be cached that returns the data you need. But that is just my opinion.
I’m also not 100% clear as to what the data is to represent or how it is to be displayed, so without mockups it is hard for me to steer you in a more descriptive direction.
I have a plugin that shows some data beside the page, the plugin is profile widget.
What is your opinion about ajaxing these data in the .js file?
Does it reduce the site speed?
You will need to add Ruby code. You will want to create a new route that can cache its data by user requested and return a response from a custom SQL query to get the data on who liked them.
Then you would call that route via an Ajax call to load into your widget.
This query might be close to what you want, tweak to suit eg. add a WHERE user_id = an id for a single user
SELECT
user_actions.user_id
, array_agg(DISTINCT user_actions.acting_user_id)
FROM user_actions
WHERE
user_actions.action_type = 2
GROUP BY user_actions.user_id
“2” is “liked” and “acting_user_id” is the “giver”
You may prefer to use AR pluck, but it would be the same table
How can I do this in plugin.rb file?
Can you tell me a simple plugin That have done this?
The Staff Notes could be a good starting place. It integrates with users and posts, so you’d want to ignore the posts part and likely integrate with the user only.
You should also look at the Who’s Online plugin. That also deals with Users. However, the big difference is the Who’s Online is a global view, not specific to the user who is logged in, so you’d need to take that into account. But it also has several advantages for you, it is utilizing the message bus to send updates and that could be useful for you.