mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-07 15:53:29 +08:00
In
be5798f6d8
we standardized the way we counted a user's accepted answers.
This makes it a little bit more obvious by refactoring the query into it
own files (queries.rb) and using that in both the user card and user
summary serializers.
Also improved the specs coverage.
Internal ref - t/149121
13 lines
355 B
Ruby
13 lines
355 B
Ruby
# frozen_string_literal: true
|
|
|
|
module DiscourseSolved
|
|
module Queries
|
|
def self.solved_count(user_id)
|
|
DiscourseSolved::SolvedTopic
|
|
.joins(answer_post: :user, topic: {})
|
|
.where(posts: { user_id: user_id, deleted_at: nil })
|
|
.where(topics: { archetype: Archetype.default, deleted_at: nil })
|
|
.count
|
|
end
|
|
end
|
|
end
|