When merging 3 posts with 4, 3 and 2 likes respectively in this exact order, the final post gets only 2 likes. I expect to see 4 likes, if not more (should be DISTINCT likes of all posts).
Example who liked posts:
Post 1: A, B, C, D (4 likes)
Post 2: A, B, E (3 likes)
Post 3: C, D (2 likes)
Resulting likes should be: A, B, C, D, E (5 likes)
P.S. A, B, C, D and E are nicknames who liked the posts.
H there! Just wanted to say that this bug is not actually a duplicate and it still exists. Just merged posts couple days ago on up-to-date Dicourse and the likes were not transferred.
Hi @codinghorror,
I was looking through this bug. I found out when we do merge_posts, we pseudo_delete all posts except one which becomes the merged post.
So for all the posts except merged_post, we delete their user_actions for was_liked. So to transfer likes, I will have to get all the was_liked actions for deleted_posts. Out of those likes, users which haven’t liked the merged_post, we can create user_action for them corresponding to merged_post.
What do you think about this approach?
Also, there is an option to recover post. When that happens, all was_liked actions are re-created too using post_action. In that case, the merged post will have new likes equal to likes to all the merged posts and recovered_post will also get back its likes thus increasing number of likes.
Oh my… this is not really an ideal started task, its actually quite fiddly and tricky as you discovered @saurabhp
I think the most correct thing to stop with this unconditional deleting of user actions and deal with elimination of duplication instead. The extra tricky thing is you need to deal with post_actions and user_actions here. Also once you do all this stuff you have to float the correct number up to the topic.
Recovery here is a nighmare, once we allow this then this turns into hell basically to implement cause we need to yank out the likes on recovery.
I kind of want to put dealing with this on the back burner.
Er what? It’s literally adding numbers together. Perhaps you misunderstood the request? We are not talking about merging topics we are talking about merging posts.
Right now merged posts effectively have their likes removed. That’s clearly wrong.
No we do not do any merging or consolidating, if we do any of that we effectively are allowing mods to perform an action they can not undo. Currently undo is very simple, delete a block of text, undo delete of other post.
I don’t think that’s a big deal, who is asking to undo a post merge? I’m saying, completely ignore dupe likes, and combine all the non-dupe likes.
It does make sense that the numbers will not add up, due to duplicate likes, e.g. if Sally likes all 3 posts, 2 of them are discarded because she liked the final merged post anyway.
Take all the post and user actions that are “like / was liked” and transfer them to the new merged post, taking care of making it a NO-OP for dupes
Don’t worry at all about the recover scenario, if you try to unmerge, some likes will end up on the wrong post by design.
Also it allow to teleport likes between posts by moderators
I just realised one more table needs touching, notifications for likes may point to the wrong posts, so that also needs fixing. So we have 3 tables at play, notifications, user_actions and post_actions .