At for example meta.discourse.org/my/summary, the “Most Liked By” column containers the correct numbers of likes and the correct users, but does not match them up correctly.
This is a little easier to see when you’re the admin for the site and can check against a data explorer query, though. I can’t easily verify it’s happened on meta, have seen the issue most clearly on my site.
Nothing special required, just visit a user summary page and check the numbers against some other source. For example using the data explorer plugin, or using the user directory in some circumstances (one of the “most liked by” for my page on my site, for example, is shown giving me more likes than he has given total on the user directory).
Does it really? That’s kind of odd. Your suggested query doesn’t really give me an easy way to evaluate the difference, although maybe I’m not using it as you intended.
In any case though, thanks for looking into it, but I think it’s really unlikely that’s the issue. The set of counts and users between the query and the summary page are literally identical (and occupy a fairly wide range, they don’t differ by one or two likes), the counts are just attributed to different users on the summary page. The counts on the summary page don’t align well with my experience on the forum, either.
I’ve been playing with this in Data Explorer (please forgive readability issues)
WITH tl AS ( SELECT SUM(topics.like_count) AS topics_like_sum
FROM topics )
, pl AS ( SELECT SUM(posts.like_count) AS posts_like_sum
FROM posts )
, pal AS ( SELECT COUNT(post_actions.id) AS pa_like_count
WHERE post_actions.post_action_type_id = 2 )
, padl AS ( SELECT COUNT(post_actions.id) AS deleted_pa_like_count
WHERE post_actions.post_action_type_id = 2
AND post_actions.deleted_at IS NOT NULL )
, bpl AS ( SELECT SUM(badge_posts.like_count) AS bp_like_sum
FROM badge_posts )
, pcl AS ( SELECT SUM(topics.like_count) AS priv_topic_like_sum
ON topics.category_id = categories.id
WHERE categories.read_restricted )
The numbers are slightly different now, looks like they are taking into account deleted/negated likes correctly, but the count-user matches are still incorrect on my site. This shouldn’t require a rebuild or a sidekiq job I need to wait for, right?
A correction is in order (as embarrassing as it s after Likes)
It should teach me to more thoroughly test before posting results.
Anyway, I decided to repro and had LikerGal1 Like the same parent Cat OPs .
Being a comparatively small localhost forum a lot of numbers have not diverged greatly and I looked for other “two occurrences events” that might be involved.
LikerGuy1 had also Liked 2 “hidden by Flags” posts.
LikerGal1 did similar, - No repro,
LikerGuy1 had also Liked 2 posts made by anonymous-mode members that were subsequently deleted by a Mod
LikerGal1 did the same - repro !!
Was it because the posts had been made in anonymous-mode?
A friendly member made a test post. Another Liked it, then it was Mod deleted. - repro !!
So unfortunately this isn’t as edge case as a topic-less category getting a Like.
It seems that Liking any post that is subsequently deleted will decrement the post like count, but will not decrement the associated topics like count.
Still a bit edge case I suppose, but maybe worth looking into if topic like count is used in value weighting algorithms.