Support merging of 2 topics with voting

AI-generated summary

A discussion on merging topics with voting in Discourse highlights an issue where votes can be lost or reset when comments are moved from one topic to another. watchmanmonitor initially reported the problem and dan provided a PR to fix it. However, alexs and JaredH pointed out inconsistencies in the voting behavior after merging topics. dan explained that votes are not duplicated if users voted on both topics, and the final count is calculated based on unique votes. He also submitted another PR to improve the clarity of vote movement and added a feature to display the number of moved and unmoved votes in the moderator post.

I had people two topics in a voting category which were essentially the same request, so I merged all comments from Topic B to Topic A, and now Topic A has no votes.

Has anyone seen an issue where votes on Topic A are lost/reset after moving a number of commits into it from Topic B?

I think I did, but don’t know if there’s any place I can tell if a Topic A ever got votes. If they were logged anywhere, I’d love to know so I can check.

7 curtidas

Agree we should fix this, for now pr-welcome

4 curtidas

Hello,

This PR should fix this.

Let’s say we have topics A and B. When topic A is merged into topic B, all users who voted topic A will automatically vote B and their votes for A will be removed.

6 curtidas

Are there any exceptions to this rule? I’ve noticed some inconsistent behaviour e.g. when I merged this topic:

Community Notice | Freetrade

into this one:

Community Notice | Freetrade

not all of the votes were carried across the latter topic. IIRC only 16 made it across.

Yes, I’ve experienced the same thing. We’re regularly merging topics. Our process is to merge to the oldest topic to preserve the chronological order of the posts. When this happen we lose the votes for the other topics.

@dan, alguma ideia sobre esses problemas?

Há uma exceção que consigo pensar.

Digamos que temos dois tópicos: A e B, cada um com 100 votos, mas 20 dos usuários que votaram em A também votaram em B. Se os dois tópicos forem mesclados, não é garantido que o tópico final terá 200 votos, pois pode haver alguns usuários que votaram em ambos os tópicos e os votos não serão duplicados.

A contagem final será = quantidade de usuários que votaram em A + quantidade de usuários que votaram em B - quantidade de usuários que votaram em A e em B. No exemplo acima (100 + 100 - 20 = 180).

2 curtidas

Fiz algumas alterações aqui e acabei de enviar um pull request para deixar as coisas mais claras. Após a aceitação deste pull request, a postagem do moderador adicionada ao tópico original será editada para incluir quantos votos foram transferidos e quantos não foram (porque o usuário já votou no tópico de destino).

4 curtidas