mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 13:03:43 +08:00
69213d2ea4
If a badge grouping happens to have been deleted a 500 error will be thrown when looking a user's badges. This fix allows the badge page to still be shown without any errors. The badge with the missing badge grouping is still displayed. I'll follow up with a separate pr/commit that will ensure if a badge grouping is deleted, all badges with that badge_grouping_id will also be updated.
16 lines
298 B
Ruby
16 lines
298 B
Ruby
# frozen_string_literal: true
|
|
|
|
class BasicUserBadgeSerializer < ApplicationSerializer
|
|
attributes :id, :granted_at, :count, :grouping_position
|
|
|
|
has_one :badge
|
|
|
|
def include_count?
|
|
object.respond_to? :count
|
|
end
|
|
|
|
def grouping_position
|
|
object.badge&.badge_grouping&.position
|
|
end
|
|
end
|