fix: exclude anonymous posts in build_course_stats #424
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
INF-887
Explanation:
When a user makes their first non-anonymous post, the system uses the "build_course_stats" function to create a new set of statistics for that user. However, there is a problem with the current implementation of the function. It counts all the posts made by a specific user, including those that are anonymous or were made anonymously to peers, before the user made their first non-anonymous post. This leads to an inaccurate count of the user's threads being saved in the database. In other words, the function doesn't filter out the posts made before the user started posting non-anonymously, causing the stored count to be incorrect.
Note: this fix is not backward compatible as that would require direct changes to the database.