Solved count in summary displaying incorrect values

Hey everyone,

After updating our Discourse instance, we seemingly have incorrect solved amounts when looking at profile summaries. Example:

I already noticed there were a couple of changes lately, including a breaking bug:

The correct amounts are obviously still available so there was likely something happening while migrating the data to the new tables?

1 Like

Thanks for writing in. I’ll have a look.

1 Like

There are some discrepancies in counting solutions in Discourse where we were including topics and posts that have already been deleted.

Before the migration, we were indicating:

John has 27 solutions because people marked his post as solution 27 times.

This is stored in the UserActions table.

After the migration, we are now counting:

John has 20 solutions because there are 20 topics where his posts are solutions

This is stored in the SolvedTopics table, and has a direct link to an existing, non-deleted topic.

There’s a subtle difference here - in the first scenario there were no validations in checking if the solution post or its topic still existed.

I’ll check in with our team which is the better number to display. Personally I am leaning counting solutions for topics that still exist.

3 Likes

I’m quite sure that this can’t be the issue — as it would only cause fewer numbers rather than more in some cases, correct? There is another example I have for you:
→ Wrong: Profile - SGS - Garuda Linux Forum
→ Right:
The image displays a user profile section showing that the user joined on April 15, 2020, has read 600 hours of content, and posted 4 hours ago, with a current streak of 5 consecutive days. (Captioned by AI)

It seems impossible to me that this counting mechanism would more than double the amount of solved post counts. Besides that (of course unconfirmed) I highly doubt that the number of deleted posts was this high in my previous example.

Thanks!

Hmmm yes 485 and 90 are too wide apart.

I believe just found the bug (though the statement about discrepancy I mentioned above is still true) –

In the previous implementation, the solution count in John’s summary is counted by the number of times anyone marked the John’s post as solution

  def solved_count
    UserAction.where(user: @user).where(action_type: UserAction::SOLVED).count
  end

In the new implementation, the solution count in John’s user summary is the number of times John marked a post as solution

  def solved_count
    DiscourseSolved::SolvedTopic.where(accepter: @user).count
  end

This explains the large difference. “solved count” changed definitions from ‘how many times you answered’ to ‘how many times you accepted’.

Will fix the bug, thanks again for the report!

I’ll also update the different counting methods used in profile popup and user summary.

4 Likes

Props to @ondrej for also mentioning Solution badge not working? to me. It looks like some discrepancies were already happening before this migration. Good thing is that we’ll be migrating to a more consistent number across Discourse and our plugins.

4 Likes

Wonderful, thank you very much! :slight_smile:

4 Likes

This is now fixed and standardised - FIX: Standardise the definition of what a solution is by nattsw · Pull Request #352 · discourse/discourse-solved · GitHub

4 Likes

This topic was automatically closed after 2 days. New replies are no longer allowed.