FEATURE: Show number of accepted answers on user card (#154)

This commit is contained in:
Bianca Nenciu 2021-08-26 14:25:39 +03:00 committed by GitHub
parent 184d2e6137
commit fafa1c22b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,6 @@
{{#if user.accepted_answers}}
<h3>
<span class="desc">{{i18n "solutions"}}</span>
{{user.accepted_answers}}
</h3>
{{/if}}

View File

@ -70,3 +70,7 @@ $solved-color: green;
aside.quote .title.title-only {
padding: 12px;
}
.user-card-metadata-outlet.accepted-answers {
display: inline-block;
}

View File

@ -687,6 +687,14 @@ SQL
}
end
add_to_serializer(:user_card, :accepted_answers) do
Post
.where(user: User.find_by_username('bar3'))
.joins(:_custom_fields)
.where(_custom_fields: { name: 'is_accepted_answer', value: 'true' })
.count
end
class ::Topic
attr_accessor :accepted_answer_user_id
end