# bug
If John created a post which is a solution in March, the user directory would show that John solution = 1.
In April, if John has not solved a topic, he would still have solution = 1 in the user directory.
# fix
reset solutions to 0 before updating
Earlier on in the migration, the update of the user directory query was erroneously switched to use post creation date instead of the date the post was solved.
This commit fixes that.
When an answer already exists, clicking "✅ Solution" on another post works, but does not commit.
This commit fixes that and also adds a test, and a transaction around accepting a solution (deleting the topic timer, previous user action, etc).
There are three locations where a user's solution query is defined
- user summary
- user card
- user directory
This PR updates the queries to use data from the new `SolvedTopics` table instead of the `UserActions` table. And adds testssssss
As part of https://github.com/discourse/discourse-solved/pull/342, some discrepancies in the old implementation resulted in solved topics linking to posts that do not exist (dangling custom field value). Causing us to see the following when there are no `answer_post`
```
NoMethodError (undefined method `user' for nil)
```
This PR prevents the error.
We are seeing some errors when migrating and adding indexes on `answer_post_id`.
```
#<StandardError:"An error has occurred, all later migrations canceled:\n\nPG::UniqueViolation: ERROR: could not create unique index \"index_discourse_solved_solved_topics_on_answer_post_id\"\nDETAIL: Key (answer_post_id)=(13006) is duplicated.\n">
```
This PR modifies the earlier migration, and also adds one before the addition of indexes to remove duplicates.
https://github.com/discourse/discourse-solved/pull/342 was deployed and observed to only have 5000 (batch size) migrated. This is an error in migration where the ids had a gap between the batch.
This PR changes the migration to just loop through all topic custom fields with each loop increasing by batch size.
This commit autoloads plugin files, and also extracts features into their own modules.
- `plugin.rb` is smaller
- external plugins like discourse-automation and discourse-assign have their own entrypoints
- solved filters as well
* FIX: don't allow or count solutions in PMs
Pretty straightforward, this ensures we don't allow users to mark a post
as a solution in a PM.
This also ensures we don't count solutions in topics that were converted
to a PM.
Internal ref t/146766
…in the new topic-status implementation (using the next `@context` from https://github.com/discourse/discourse/pull/30940)
This roughly matches the old implementation (but there it was displayed in some places but not in others mostly because of implementation details/bugs)